AWS SSH 登录EC2 将"ec2-user" 切换成 "r

2018-05-11  本文已影响0人  Jacen7

1、先用ec2-user登录EC2,并切换到root

    ssh ec2-user@ip

    sudo -s

2、修改PermitRootLogin、UsePAM

    [root@hostname ~]# vi /etc/ssh/sshd_config

    PermitRootLogin 改成 yes

    UsePAM 改成 no

    保存退出

3、修改authorized_keys文件

    sed -ri 's/^/#/;s/sleep 10"\s+/&\n/' /root/.ssh/authorized_keys

4、重启sshd服务

    service sshd restart            ##linux 7之前的版本通常使用

    systemctl restart sshd.service  ##linux 7之后使用(替代service、chkconfig)

5、root登录

    ssh root@ip

上一篇下一篇

猜你喜欢

热点阅读