如何處理 ssh 設定和密碼

如何處理 ssh 設定和密碼

為什麼從 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*"""") 執行("""評估ssh-agent -s;ssh-add /root/.ssh/git_id_rsa""")

織物的相關輸出:

[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

..太棒了..我可以克隆而不需要密碼。為什麼它在織物上不起作用?

答案1

因為身分文件是私鑰,而不是公鑰:

Host *github.com
    IdentityFile ~/.ssh/git_id_rsa # Without the .pub

相關內容