将亚马逊aws的ec2服务器的登陆方式改为密码登陆

1.在用密钥登陆ec2后,为root用户创建密码:

sudo passwd root

系统会让你输入两次密码

2.切换为root用户,并且编辑sshd_config文件,PasswordAuthentication no,把no改成yes。使系统允许密码登陆

su root

vim /etc/ssh/sshd_config

3.重启ssh服务

/etc/init.d/ssh restart

ssh位置因系统而异

4.为原来的用户添加密码,我原来的用户是ubuntu

passwd ubuntu

提示输入两次密码

5.此时还是不能用root登录,只能用ubuntu登陆,如果需要使用root用户登陆需要修改sshd_config文件,参考:http://bbs.qcloud.com/thread-11554-1-1.html

vim /etc/ssh/sshd_config

找到  PermitRootLogin 这项 将其改为 yes

6.再次重启ssh服务。参考了以上链接可以使用下面的方式重启ssh

service ssh  restart

猜你喜欢

转载自www.cnblogs.com/liluxiang/p/9284764.html