2016-08-07 269 views
-1

有許多與此授權問題相關的許多類似的問題和答案---「權限被拒絕(publickey)」。但是,它們都不適用於我的問題...權限被拒絕(publickey)Git和AWS EC2

這是我的情況:我使用亞馬遜網絡服務器EC2,並且我的PC與服務器連接良好。對於下一步,我試圖在服務器上安裝git。我希望完成的結果是當我從本地推送時更新服務器端。但這裏的問題出現了:「權限被拒絕(公鑰)」

OpenSSH_6.9p1, LibreSSL 2.1.8 
debug1: Reading configuration data /Users/IvyLin/.ssh/config 
debug1: Reading configuration data /etc/ssh/ssh_config 
debug1: /etc/ssh/ssh_config line 21: Applying options for * 
debug1: /etc/ssh/ssh_config line 56: Applying options for * 
debug1: Connecting to 52.68.24.4 [52.68.24.4] port 22. 
debug1: Connection established. 
debug1: identity file /Users/IvyLin/.ssh/id_rsa type 1 
debug1: key_load_public: No such file or directory 
debug1: identity file /Users/IvyLin/.ssh/id_rsa-cert type -1 
debug1: key_load_public: No such file or directory 
debug1: identity file /Users/IvyLin/.ssh/id_dsa type -1 
debug1: key_load_public: No such file or directory 
debug1: identity file /Users/IvyLin/.ssh/id_dsa-cert type -1 
debug1: key_load_public: No such file or directory 
debug1: identity file /Users/IvyLin/.ssh/id_ecdsa type -1 
debug1: key_load_public: No such file or directory 
debug1: identity file /Users/IvyLin/.ssh/id_ecdsa-cert type -1 
debug1: key_load_public: No such file or directory 
debug1: identity file /Users/IvyLin/.ssh/id_ed25519 type -1 
debug1: key_load_public: No such file or directory 
debug1: identity file /Users/IvyLin/.ssh/id_ed25519-cert type -1 
debug1: Enabling compatibility mode for protocol 2.0 
debug1: Local version string SSH-2.0-OpenSSH_6.9 
debug1: Remote protocol version 2.0, remote software version OpenSSH_6.6.1 
debug1: match: OpenSSH_6.6.1 pat OpenSSH_6.6.1* compat 0x04000000 
debug1: Authenticating to 52.68.24.4:22 as 'git' 
debug1: SSH2_MSG_KEXINIT sent 
debug1: SSH2_MSG_KEXINIT received 
debug1: kex: server->client [email protected] <implicit> none 
debug1: kex: client->server [email protected] <implicit> none 
debug1: expecting SSH2_MSG_KEX_ECDH_REPLY 
debug1: Server host key: ecdsa-sha2-nistp256 SHA256:ieQEskLZ3tiW76F5KPhlQfHcGYFW+SifiIDQnBUZHmY 
debug1: Host '52.68.24.4' is known and matches the ECDSA host key. 
debug1: Found key in /Users/IvyLin/.ssh/known_hosts:5 
debug1: SSH2_MSG_NEWKEYS sent 
debug1: expecting SSH2_MSG_NEWKEYS 
debug1: SSH2_MSG_NEWKEYS received 
debug1: SSH2_MSG_SERVICE_REQUEST sent 
debug1: SSH2_MSG_SERVICE_ACCEPT received 
debug1: Authentications that can continue: publickey 
debug1: Next authentication method: publickey 
debug1: Offering RSA public key: /Users/IvyLin/.ssh/id_rsa 
debug1: Authentications that can continue: publickey 
debug1: Offering RSA public key: /Users/IvyLin/.ssh/id_rsa 
debug1: Authentications that can continue: publickey 
debug1: Trying private key: /Users/IvyLin/.ssh/id_dsa 
debug1: Trying private key: /Users/IvyLin/.ssh/id_ecdsa 
debug1: Trying private key: /Users/IvyLin/.ssh/id_ed25519 
debug1: No more authentication methods to try. 
Permission denied (publickey). 

有一兩件事我不知道是我應該把公共密鑰到底是什麼?服務器中已有一個用於「驗證服務器連接」的.ssh文件,路徑爲:~/.ssh,它適用於我。 就git的ssh密鑰而言,我在git文件夾內創建了另一個.ssh文件夾,路徑爲:~/home/git/.ssh。連接期間查找哪個文件?雖然我試圖把公鑰放入~/.ssh,但仍然不起作用...

我一直呆在那裏很長時間,真的很感謝如果有人能幫助我!實現「更新爲推」的解決方法也將幫助我!

+0

什麼是包含您密鑰的文件的名稱? – Jakuje

+0

用於在服務器端存儲公鑰,它是'〜/ .ssh/authorized_keys'@ Jakuje –

+0

不,在您的本地計算機中。如果您將其存儲在服務器上,請確保對'ls -l〜〜/ .ssh〜/ .ssh/authorized_keys'的權限。 – Jakuje

回答

0

我想知道的一件事是我應該在哪裏準確地公鑰?

你必須把公鑰放在你的帳戶下的git服務器上。

它在連接期間查找哪個文件?

您必須將~/.ssh/id_rsa.pub複製到您的git的服務器帳戶

+0

嗨!謝謝你的回覆!我已經把公鑰放到了服務器端的'〜/ .ssh/authorized_keys'中,但是它仍然會給出錯誤......任何其他可能性都會出錯?實際上,如果兩個密鑰都應該放在服務器帳戶下,是否意味着它們可以合併爲一個?或者我們需要配置文件來區分它們...我感到困惑... –

+0

你需要區分和使用配置文件 – CodeWizard

相關問題