如何使用非ec2用户loginEC2实例?

如何使用非ec2用户帐户在amazon linux ami中login?

#useradd -m sample #passwd sample set password #cat /etc/passwd sample:x:508:1002::/home/monitor/sample:/bin/bash # cat /home/monitor/sample/.ssh/authorized_keys command="echo 'Please login as the ec2-user user rather than root user.';echo;sleep10" ssh-rsa xxxxxxxxx # chown -R sample /home/monitor/sample/.ssh 

我还将/root/.ssh/authorized_keys复制到新用户的.ssh目录中

在login时服务器说'服务器拒绝我们的密钥'和没有支持authentication方法可用popup。

如何将样本与我现有的密钥对相关联?

您应该将/home/ec2-user/.ssh/authorized_keys复制到新用户的authorized_keys文件中,而不是复制/root/.ssh/authorized_keys。 您还需要确保权限设置正确。

例如:

 rsync -a /home/ec2-user/.ssh /home/monitor/sample/ chown -R sample:sample /home/monitor/.ssh