AWS EC2 免费VPS ‘ec2
AWS的VPS 免费一年用起来倒也舒服,只是每次登录有点无奈要用ec2-user登录,下面教大家切换root登录,首先用EC2-user登录:
https://s4.运维网.com/wyfs02/M02/88/E9/wKiom1gANZ-Q2WheAACJu1ZRyUY147.png-wh_500x0-wm_3-wmp_4-s_1604978137.png
创建root的密码,输入如下命令:
然后会提示你输入new password。输入一个你要设置的root的密码,需要你再输入一遍进行验证
https://s5.运维网.com/wyfs02/M00/88/E5/wKioL1gANrHASAdpAACXNdXCRj8288.png-wh_500x0-wm_3-wmp_4-s_4131463712.png
接下来,切换到root身份,输入如下命令:
https://s5.运维网.com/wyfs02/M00/88/E6/wKioL1gAN4WQ--ntAACYCALj0Jc912.png-wh_500x0-wm_3-wmp_4-s_3307305363.png
使用root身份编辑亚马逊云主机的ssh登录方式,找到 PasswordAuthentication no,把no改成yes。输入:
vim /etc/ssh/sshd_config 接下来,要重新启动下sshd,如下命令(两种方式):
正常启动:sudo /sbin/service sshd restart
高版本Centos7或者redhat7.2的情况下:#/bin/systemctl start sshd.service 然后再切换到root身份
su root 再为原来的”ec2-user”添加登录密码。如下命令:
passwd ec2-user 按提示,两次输入密码。
修改sshd配置文件
vi /etc/ssh/sshd_config PermitRootLogin这行改为
PermitRootLogin yes PasswordAuthentication no改为
PasswordAuthentication yes UsePAM yes改为
UsePAM no 重启AWS VPS,就可以使用root正常登陆了
页:
[1]