为什么从 github 克隆时会要求我输入密码??
git clone [email protected]:test/testchef.git
Cloning into 'chef'...
The authenticity of host 'github.com (xxx.xxx.xxx.xxx)' 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
Warning: Permanently added 'github.com,xxx.xxx.xxx.xxx' (RSA) to the list of known hosts.
Enter passphrase for key '/root/.ssh/git_id_rsa.pub':
这是我的 ssh 配置文件:
Host *github.com
IdentityFile ~/.ssh/git_id_rsa.pub
如果我从 fabric 运行..我没有收到任何错误,但是如果我尝试并克隆 def bootstrap(),我会被提示输入密码:put('ssh_config','/root/.ssh/config') put('git_id_rsa.pub','/root/.ssh/git_id_rsa.pub') put('git_id_rsa','/root/.ssh/git_id_rsa') run("""chmod 600 /root/.ssh/git_id_rsa*""") run("""eval ssh-agent -s
;ssh-add /root/.ssh/git_id_rsa""")
Fabric 的相关输出:
[107.170.196.221] out: Agent pid 2285
[107.170.196.221] out: Identity added: /root/.ssh/git_id_rsa (/root/.ssh/git_id_rsa)
[107.170.196.221] out:
我登录服务器并从命令行运行以下命令 eval ssh-agent -s
;ssh-add /root/.ssh/git_id_rsa git clone[电子邮件保护]:测试/testchef.git
..太棒了..我可以克隆而不需要密码。为什么它不能从 fabric 中工作?
答案1
因为身份文件是私钥,而不是公钥:
Host *github.com
IdentityFile ~/.ssh/git_id_rsa # Without the .pub