可以以 ubuntu 用户身份连接到 EC2,但不能以我创建的用户身份连接
我创建了一个新的 ebs 支持的 EC2 实例和必要的密钥对。现在我可以以 ubuntu 用户身份连接到该实例。一旦我这样做了,我创建了另一个用户并将其添加到 sudoers 列表中,但我无法作为我创建的新用户连接到该实例。
我收到以下错误。我使用相同的密钥来连接我创建的新用户。有人可以帮助我吗?我在这里错过了什么吗?
Permission denied (publickey)"
I created a new ebs backed EC2-instance and the necessary key-pair. Now I am able to connect to the instance as ubuntu user. Once i did that I created another user and added it to the sudoers list but I am unable to connect to the instance as the new user I created.
I get the following error. I am using the same key to connect with the new user i created. Can somebody help me. Am I missing something here?
Permission denied (publickey)"
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
好吧,我想我明白了。
第一种技术是通过密码登录。这个想法是以 ubuntu 用户或 root 用户身份登录并转到 /etc/ssh/sshd_config 文件并将 PasswordAuthentication 设置为 yes 并运行
/etc/init.d/ssh reload
如果您现在尝试连接,ec2 允许您使用创建的用户的密码进行登录。虽然这并不是真正安全。
其次,您创建一个密钥对并复制 id-rsa.pub 文件并将其移动到 /home/new-user/.ssh/authorized_keys 文件并将权限更改为 600 并分配给适当的用户(new-user in本案)。
我发现这非常有用
http://blog.taggesell.de/index.php?/archives/73-Managing-Amazon-EC2-SSH-login-and-protecting-your-instances.html
Okay I think i figured it out.
The first technique is to login by password. The idea is to login as the ubuntu user or root user and go to /etc/ssh/sshd_config file and turn the PasswordAuthentication to yes and run
/etc/init.d/ssh reload
If you try to connect now you ec2 allows you to log with the password of the user that was created. Though this is not really secure.
Second is you create a key-pair and copy the id-rsa.pub file and move it to the /home/new-user/.ssh/authorized_keys file and change permissions to 600 and assign to the appropriate user(new-user in this case).
I found this to be amazingly useful
http://blog.taggesell.de/index.php?/archives/73-Managing-Amazon-EC2-SSH-login-and-protecting-your-instances.html
SSH 对目录和文件权限非常挑剔。确保:
拥有将您的公钥放入authorized_keys 文件中。
您可以以 root 用户身份执行所有这些操作。暂时不需要在 /etc/ssh/ssh_config 中允许密码。
SSH is very picky about the directory and file permissions. Make sure that:
Copy your public key into the authorized_keys file.
You can do all that as a root user. There is no need to allow temporarily in /etc/ssh/ssh_config to passwords.
Sid,我按照你提到的做了,但我仍然遇到同样的错误
需要重新启动才能使其工作。 (以防万一其他人希望这种不安全的方法起作用)公钥方法是使其与远程桌面应用程序一起使用的主要痛苦
Sid, I did what you mentioned but I still got the same error
It took a reboot to get it to work. (Just in case anyone else wants this insecure method to work) The public key method is a major pain to make it work with remote desktop apps