今天尝试研究亚马逊的云主机EC2,遇到了一个问题,我在xshell连接无法root登录,只能使用ec2-user登录。这是EC2默认的用户登录的,所以需要切换到root用户登录,需要先执行
$ sudo passwd root
Changing password for user root.
New password:
Retype new password:
passwd: all authentication tokens updated successfully.
$ su - root
Password:
编辑sshd_config
# vi /etc/ssh/sshd_config
#PasswordAuthentication yes的注释打开
重启sshd.service服务
# su - ec2-user
Last login: Tue Oct 23 06:21:47 UTC 2018 from 114.242.26.55 on pts/0
# sudo /sbin/service sshd restart
Redirecting to /bin/systemctl restart sshd.service
$
给默认账户配置密码(个人需要)
$ sudo passwd ec2-user
Changing password for user ec2-user.
New password:
Retype new password:
passwd: all authentication tokens updated successfully.