且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

麻烦连接到Amazon EC2上的SSH

更新时间:2022-11-13 19:35:26

  

无法将主机添加到已知主机列表(/Users/oktolab/.ssh/known_hosts)

什么是 /Users/oktolab/.ssh/known_hosts

许可

下面的命令来运行修复权限:

  CHMOD 0600 /Users/oktolab/.ssh/known_hosts
 

另外,你能提供您所运行的确切SSH命令,因为:

  

阅读PEM私钥进行:类型RSA DEBUG1:身份验证,可以继续:公钥DEBUG1:没有更多的认证方法去尝试。权限被拒绝(公钥)。

如果你使用了大量的时间上面的错误出现 EC2用户而不是的Ubuntu 作为用户名和副反之亦然。在你的情况,这似乎是Ubuntu的图像,它应该是的Ubuntu 。这些东西将被澄清,一旦你提供确切的SSH命令,你正在运行

I'm trying to connect to my EC2 Instances on Amazon. When you connect an error - Permission denied (publickey). Installing cmhod 400 myPem.pem file does not help. Connection log:

OpenSSH_6.2p2, OSSLShim 0.9.8r 8 Dec 2011 debug1: Reading configuration data /etc/ssh_config debug1: /etc/ssh_config line 20: Applying options for * debug1: Connecting to 54.214.31.168 [54.214.31.168] port 22. debug1: Connection established. debug1: identity file wenglePemNew.pem type -1 debug1: identity file wenglePemNew.pem-cert type -1 debug1: Enabling compatibility mode for protocol 2.0 debug1: Local version string SSH-2.0-OpenSSH_6.2 debug1: Remote protocol version 2.0, remote software version OpenSSH_5.9p1 Debian-5ubuntu1 debug1: match: OpenSSH_5.9p1 Debian-5ubuntu1 pat OpenSSH_5* debug1: SSH2_MSG_KEXINIT sent debug1: SSH2_MSG_KEXINIT received debug1: kex: server->client aes128-ctr hmac-md5 none debug1: kex: client->server aes128-ctr hmac-md5 none debug1: SSH2_MSG_KEX_DH_GEX_REQUEST(1024<1024<8192) sent debug1: expecting SSH2_MSG_KEX_DH_GEX_GROUP debug1: SSH2_MSG_KEX_DH_GEX_INIT sent debug1: expecting SSH2_MSG_KEX_DH_GEX_REPLY debug1: Server host key: RSA (code) The authenticity of host '54.214.31.168 (54.214.31.168)' can't be established. RSA key fingerprint is (code). Are you sure you want to continue connecting (yes/no)? yes Failed to add the host to the list of known hosts (/Users/oktolab/.ssh/known_hosts). debug1: ssh_rsa_verify: signature correct debug1: SSH2_MSG_NEWKEYS sent debug1: expecting SSH2_MSG_NEWKEYS debug1: SSH2_MSG_NEWKEYS received debug1: Roaming not allowed by server debug1: SSH2_MSG_SERVICE_REQUEST sent debug1: SSH2_MSG_SERVICE_ACCEPT received debug1: Authentications that can continue: publickey debug1: Next authentication method: publickey debug1: Trying private key: wenglePemNew.pem debug1: read PEM private key done: type RSA debug1: Authentications that can continue: publickey debug1: No more authentication methods to try. Permission denied (publickey).

AMI creation and deployment of a new instance with a new pem file did not help.

What's need to do to connect to the server?

Failed to add the host to the list of known hosts (/Users/oktolab/.ssh/known_hosts)

What are the permission for /Users/oktolab/.ssh/known_hosts ?

Run below command to fix the permission:

chmod 0600 /Users/oktolab/.ssh/known_hosts

Also, could you provide the exact SSH command that you are running because:

read PEM private key done: type RSA debug1: Authentications that can continue: publickey debug1: No more authentication methods to try. Permission denied (publickey).

A lot of time above error appears if you use ec2-user instead of ubuntu as username and vice-versa. In your case, this seems to be ubuntu image so it should be ubuntu. These things will be clarified once you provide the exact ssh command you are running