为什么不能ssh-copy-id到EC2实例?


9

我在EC2上有一个ubuntu Natty实例,可以通过

ssh -v -i ec2-keypair ubuntu@ubuntu@XXXX.compute-1.amazonaws.com

但是我想减少密码设置。所以我尝试了这些选项,但没有任何效果:

 $ ssh-copy-id -i ~/.ssh/id_rsa.pub ubuntu@XXXX.compute-1.amazonaws.com
Permission denied (publickey).

 $ ssh-copy-id -i ~/.ssh/ec2-keypair ubuntu@XXXX.compute-1.amazonaws.com
/usr/bin/ssh-copy-id: ERROR: No identities found

 $ ssh-copy-id -i ~/.ssh/id_rsa.pub root@XXXX.compute-1.amazonaws.com
Permission denied (publickey).

Answers:


20

我要跑步

ssh-add ~/.ssh/ec2-keypair

我仍然为postgres和我的管理员普通用户执行此操作,当我ssh-copy-id -f -i /var/lib/postgres/.pubfilename ubuntu@ec2-domain仍然运行时仍然出现权限被拒绝错误。
Piyush S. Wanare

请注意,在某些环境中,eval "$(ssh-agent)"如果看到Could not open a connection to your authentication agent
azatar

1

我遇到了同样的问题:在AWS EC2实例上ssh-copy-id给出了错误Permission denied (publickey)。我确定我使用正确设置了所有权限chmod

另外,我需要/etc/ssh/sshd_config

PasswordAuthentication no

PasswordAuthentication yes

我想那是因为ssh-copy-id要求您输入密码。

然后错误消失了。


请注意,尽管将PasswordAuthentication从“ no”更改为“ yes”可以将您锁定在EC2实例之外。
Kingz 2014年
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.