在Cygwin上使用Git:无法将主机添加到已知主机列表

11

我正在使用 Windows 7 上的 Cygwin Git,在执行任何需要通过 SSH 与 GitHub 通信的操作时,我都会收到以下消息:

Could not create directory '/home/ltb/.ssh'.
The authenticity of host 'github.com (192.30.252.129)' can't be established.
RSA key fingerprint is 16:27:ac:a5:76:28:2d:36:63:1b:56:4d:eb:df:a6:48.
Are you sure you want to continue connecting (yes/no)?

到目前为止,我已经理解了上面的情况。但是一旦我输入“yes”,SSH应该能够将Github密钥插入到known_hosts文件中并继续进行。然而,每次我都会收到以下错误消息:
Failed to add the host to the list of known hosts (/home/ltb/.ssh/known_hosts).

我做错了什么?

mkdir -p /home/ltb/.ssh - Smart Manoj
1个回答

9
我写了一篇博客文章来解决这个问题。解决方案在于你的cygwin主目录很可能在/cygdrive/c/home/ltb/下,而不是你上面列出的/home/ltb/。你可以按照以下步骤进行修复:
  1. 找到passwd文件,通常位于C:\cygwin\etc\
  2. 使用你喜欢的编辑器打开它
  3. 在以你的用户名开头的那一行中,将部分内容从/home/<user>修改为/cygdrive/c/home/<user>,其中<user>是你的cygwin用户名。如果路径不同,请相应地进行调整。
  4. 保存更改并重新启动Cygwin终端
希望能对你有所帮助...

14
对于较新的Cygwin,您需要编辑/etc/nsswitch.conf文件并添加db_home: windows,然后重启Cygwin。参见这个Superuser答案 - Jake Cobb

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接