可以以 ubuntu 用户身份连接到 EC2,但不能以我创建的用户身份连接

发布于 2024-09-05 04:15:31 字数 232 浏览 3 评论 0原文

我创建了一个新的 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

遥远的她 2024-09-12 04:15:31

好吧,我想我明白了。

第一种技术是通过密码登录。这个想法是以 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

甜中书 2024-09-12 04:15:31

SSH 对目录和文件权限非常挑剔。确保:

  1. 目录 /home/username/.ssh 具有权限“700”并且由用户(不是 root!)
  2. 拥有 /home/username/ssh/authorized_keys 具有权限“600”并且由用户

拥有将您的公钥放入authorized_keys 文件中。

sudo chown -R username:username /home/username/.ssh
sudo chmod 0700 /home/username/.ssh
sudo chmod 0600 /home/username/.ssh/authorized_keys

您可以以 root 用户身份执行所有这些操作。暂时不需要在 /etc/ssh/ssh_config 中允许密码。

SSH is very picky about the directory and file permissions. Make sure that:

  1. The directory /home/username/.ssh has permission "700" and is owned by the user (not root!)
  2. The /home/username/ssh/authorized_keys has permission "600" and is owned by the user

Copy your public key into the authorized_keys file.

sudo chown -R username:username /home/username/.ssh
sudo chmod 0700 /home/username/.ssh
sudo chmod 0600 /home/username/.ssh/authorized_keys

You can do all that as a root user. There is no need to allow temporarily in /etc/ssh/ssh_config to passwords.

友谊不毕业 2024-09-12 04:15:31

Sid,我按照你提到的做了,但我仍然遇到同样的错误

第一种技术是通过密码登录。 ...

需要重新启动才能使其工作。 (以防万一其他人希望这种不安全的方法起作用)公钥方法是使其与远程桌面应用程序一起使用的主要痛苦

Sid, I did what you mentioned but I still got the same error

The first technique is to login by password. ...

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文