2 个 ec2 服务器之间无法使用密码 ssh - 权限被拒绝(公钥)

2 个 ec2 服务器之间无法使用密码 ssh - 权限被拒绝(公钥)

我创建了 2 个 aws ubuntu 12.04 服务器

我将id_rsaid_rsa.pub文件上传到两个服务器

我在两台服务器上运行了下面的内容

chmod 600 id_rsa*
eval `ssh-agent -s`
ssh-add ~/.ssh/id_rsa

我做错了什么?

ssh [email protected]
The authenticity of host 'ec2-54-183-89-212.us-west-1.compute.amazonaws.com (172.31.5.34)' can't be established.
ECDSA key fingerprint is 2a:3a:43:9d:e8:aa:50:2f:f3:83:c4:e2:2e:b2:f2:e7.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'ec2-54-183-89-212.us-west-1.compute.amazonaws.com,172.31.5.34' (ECDSA) to the list of known hosts.
Permission denied (publickey).

答案1

ssh-add将密钥添加到 SSH 代理,用于在打开的连接中进行身份验证服务器,而不是与服务器的连接。因此您必须执行以下操作:

cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys

此外, 上的权限~/.ssh/id_rsa.pub不需要是600,因为它是公钥。它可以是644而不会损失安全性。

相关内容