2017-02-22 112 views
-1

我試圖從一個centos 7機器上ssh進入我的ec2實例。我已將.pem文件添加到.ssh文件夾。運行ssh時權限被拒絕錯誤

我錯過了什麼?

[[email protected] .ssh]# cd /home/###/.ssh/ 
[[email protected] .ssh]# ls 
##.pem 

[email protected] .ssh]# ssh [email protected] -vvv 


debug1: Trying private key: /root/.ssh/id_rsa 
debug3: no such identity: /root/.ssh/id_rsa: No such file or directory 
debug1: Trying private key: /root/.ssh/id_dsa 
debug3: no such identity: /root/.ssh/id_dsa: No such file or directory 
debug1: Trying private key: /root/.ssh/id_ecdsa 
debug3: no such identity: /root/.ssh/id_ecdsa: No such file or directory 
debug1: Trying private key: /root/.ssh/id_ed25519 
debug3: no such identity: /root/.ssh/id_ed25519: No such file or directory 
debug2: we did not send a packet, disable method 
debug1: No more authentication methods to try. 
Permission denied (publickey,gssapi-keyex,gssapi-with-mic). 
+0

你試過'sudo'然後運行命令嗎? – Option

+1

查看https://wiki.centos.org/HowTos/Network/SecuringSSH特別確保你CHMOD正確的相關文件 –

回答

1

你的root用戶 - 這並不重要,如果你有在同一目錄中的PEM文件,它會在默認目錄中查找(/root/.ssh你的情況) 。如果你想使用PEM文件,使用「-i」命令行選項:

ssh -i something.pem [email protected] -vvv 
1

我看你使用的是root的shell,但你的問題狀態的關鍵憑據存儲在用戶的主目錄。請問這項工作作爲用戶,即

[[email protected] .ssh]# su - ### 
[###@localhost ~]$ ssh [email protected] -vvv 

您也可以嘗試覆蓋在SSH客戶正在尋找的.ssh文件,儘管SSH得到挑剔不匹配的文件權限,即

[[email protected] ~]# ssh -i ~###/.ssh/something.pem [email protected] -vvv 

可以存儲連接「配置文件」在〜/ .ssh /配置,即

Host ec2 
    HostName 10.100.140.52 
    IdentityFile ~/.ssh/identity_file 
0

我創建的實例,然後我能夠使用SSH連接實例。 謝謝大家。