我非常想随身携带 Git 安装,因此我通过 PortableApps 安装了 GitPortable。 不幸的是,git-bash 中提供的 OpenSSH 实用程序坚持将 .ssh 文件夹放置/搜索在一个无意义的位置 (C/.ssh)。
现在,我看到其他人也有同样的问题,但解决方案通常是将 HOME 设置为 Windows 环境变量。但这对我不起作用。
从常用的 Windows 命令提示符处:
C:\Users\snb>echo %HOME%
C:\Users\snb
显示环境变量显然设置正确。 来自 git-bash:
snb@SNB-WORKSTATION /c/Users/snb
$ echo $HOME
C:\Users\snb
表明 git-bash 同意。但是,如果我测试 SSH 命令,OpenSSH 对于在哪里找到 .ssh 文件夹的想法是完全错误的:
snb@SNB-WORKSTATION /c/Users/snb
$ ssh -T <a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="24434d5064464d504651474f41500a4b5643" rel="noreferrer noopener nofollow">[email protected]</a>
Could not create directory 'C/.ssh'.
The authenticity of host 'bitbucket.org (131.103.20.167)' can't be established.
RSA key fingerprint is 97:8c:1b:f2:6f:14:6b:5c:3b:ec:aa:46:46:74:7c:40.
Are you sure you want to continue connecting (yes/no)?
我不知道如何让 GitPortable 安装中的 OpenSSH 了解我的主目录在哪里。除了屈服并只安装适用于 Windows 的 Git 之外,您还有其他想法吗?
编辑:
OpenSSH 版本是:
$ ssh -V
OpenSSH_6.6.1p1, OpenSSL 1.0.1i 6 Aug 2014
使用 git-cmd.bat 时,该命令在 Windows 命令提示符中使用正确的 .ssh 文件夹位置:
C:\Users\snb>ssh -T <a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="492e203d092b203d2b3c2a222c3d67263b2e" rel="noreferrer noopener nofollow">[email protected]</a>
The authenticity of host 'bitbucket.org (131.103.20.168)' can't be established.
RSA key fingerprint is 97:8c:1b:f2:6f:14:6b:5c:3b:ec:aa:46:46:74:7c:40.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'bitbucket.org,131.103.20.168' (RSA) to the list of known hosts.
Enter passphrase for key '/c/Users/snb/.ssh/id_rsa':
但我真的很讨厌 cmd.exe,我需要它才能为 git-bash 工作! :)
git-bash 使用的 SSH 命令是:
$ which ssh
/bin/ssh
/bin 文件夹位于 GitPortable 安装内部,因此这将是随 GitPortable 分发的 OpenSSH 版本。
此GitPortable基于msysgit PortableGit-1.9.5-preview20141217 github commit
最佳答案
bash session 中 HOME 的正确路径应设置为:
export HOME=/c/Users/snb
这将使其与 unix shell 中的 ssh 兼容。
使用posix path考虑到 Git is running on top of a posix run-time environment 似乎更安全.
关于ssh - 在 GitPortable 中正确设置 SSH home,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28327741/