0

我目前使用ssh連接遠程aws實例,這是ubuntu 。首先我可以完美地連接它。但是,我將ec2實例的ssh密鑰(.pem文件)從Download下載到我自己的筆記本上的.ssh文件夾後,它顯示Could not resolve hostname mypath/myssh.pem provided, or not known。我很確定,用戶名和服務器名稱沒有任何問題。 有什麼我缺少設置?
此外,雖然ssh -v這表明debug1: Trying private key: Mypathtokey/my.pem debug1: Authentications that can continue: publickey debug1: No more authentication methods to try.AWS連接被拒絕

編輯 我的命令

ssh -i ~/.ssh/my.pem [email protected] 

我還設置ssh aws在ssh_config中。當使用ssh -vvv aws時,它顯示

debug1: Next authentication method: publickey 
debug1: Trying private key: /Users/mypath/.ssh/ssh.pem 
debug2: storing passphrase in keychain 
debug3: Search for existing item with query: { 
    acct = "/Users/mypath/.ssh/ssh.pem"; 
    agrp = "com.apple.ssh.passphrases"; 
    class = genp; 
    labl = "SSH: /Users/mypath/.ssh/ssh.pem"; 
    nleg = 1; 
    "r_Ref" = 1; 
    svce = OpenSSH; 
} 
debug3: Item already exists in the keychain, updating. 
debug3: sign_and_send_pubkey: RSA SHA256: my rsa sha256 keyvalue 
debug3: receive packet: type 51 
debug1: Authentications that can continue: publickey 
debug2: we did not send a packet, disable method 
debug1: No more authentication methods to try. 
Permission denied (publickey). 
+0

顯示您正在使用的命令。 – Justinas

+0

*「將我的ssh密鑰移到另一個文件夾後」* ...哪個密鑰?在服務器或客戶端?爲什麼? – Jakuje

+0

我將ec2實例的ssh密鑰(.pem文件)從Download下載到我自己的筆記本上的.ssh文件夾,因爲我試圖在我的Downloads文件中首次與ec2實例建立連接 – EEEEEric

回答

0

您是否檢查了.pem文件的權限?嘗試將其更改爲600並連接。希望能夠解決問題。