我正在尝试使用以下命令通过 SSH 从受密码保护的 headless 服务器进行 Git 克隆。我正在将 Cygwin 与 OpenSSH 一起使用。我可以使用 Cygwin 对服务器进行交互式 SSH,而不会出现问题。该问题仅出现在 Cygwin 中,而不出现在 Windows 命令提示符中。
git clone ssh://username@server.edu:path/to/repo/reponame
我没有收到任何类型的密码提示。我收到以下错误:
Cloning into 'reponame'...
ssh_askpass: exec(/usr/lib/ssh/ssh-askpass): No such file or directory
Permission denied, please try again.
ssh_askpass: exec(/usr/lib/ssh/ssh-askpass): No such file or directory
Permission denied, please try again.
ssh_askpass: exec(/usr/lib/ssh/ssh-askpass): No such file or directory
username@server.edu: Permission denied (publickey,password).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
我假设这是由 SSH 和 Cygwin 设置引起的。
到目前为止,我尝试过的不成功的“解决方案”是:
git clone ssh://username:password@server.edu:path/to/repo/reponame
取消设置 GIT_ASKPASS
取消设置 SSH_ASKPASS
并重试克隆。
最终奏效的解决方案是打开一个 Windows 命令提示符并使用它而不是 Cygwin 终端。 Cygwin 中的哪些设置可能导致问题,我该如何解决?
最佳答案
首先,考虑使用Git for Windows来自 CMD(或 git bash):您根本不需要 Cygwin。这意味着使用简化的 PATH 从 git bash 测试您的 ssh。
set G=c:\path\to\latest\git
set PATH=%G%\bin;%G%\usr\bin;%G%\mingw64\bin
set PATH=%PATH%;C:\windows\system32;C:\windows\System32\Wbem;C:\windows\System32\WindowsPowerShell\v1.0\
我知道它已经在 CMD 中工作了,但是使用简化的 PATH 通常是一种很好的做法,可以验证它是否可以满足我们的需要(而不是因为其他一些程序 PATH)
其次,在 Cygwin 中(如果您必须使用它),请至少尝试
ssh -Tv ssh://username@server.edu
查看相同的错误是否仍然存在,以及详细输出是否有更多线索。查看
$HOME
值( echo $HOME
)查看是否 $HOME/.ssh
确实有您的私有(private)/公共(public)( id_rsa
/id_rsa.pub
) key 。
关于在 Cygwin 中通过 SSH 进行 Git 克隆不提示输入密码,而是输出错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50073084/