Loading... 一、利用密钥登录系统,先修改root用户密码。 `sudo passwd root` 然后会提示你输入new password。输入一个你要设置的root的密码,然后再输入一遍进行确认。 二、输入以下命令,切换root身份。 `su root` 三、利用vim命令修改/etc/ssh/sshd_config文件,具体vim命令的使用请找度娘。 `vim /etc/ssh/sshd_config` 然后把其中的PasswordAuthentication no的no改成yes,然后把PermitRootLogin forced-commands-only 的`No`(AWS可能`forced-commands-only`)改成`yes`,如果发现`PermitRootLogin`前有`#`,意味着这项被注释掉了,那就要把#去掉。然后保存退出。 四、最后执行以下命令,重启sshd。 `service sshd restart` 五、这样就能以root用户登录系统了。 ``` #!/bin/bash echo root:Passwd123 |sudo chpasswd root sudo sed -i 's/^#\?PermitRootLogin.*/PermitRootLogin yes/g' /etc/ssh/sshd_config; sudo sed -i 's/^#\?PasswordAuthentication.*/PasswordAuthentication yes/g' /etc/ssh/sshd_config; sudo service sshd restart ``` > 引用自:「风之逸&缘冰」 https://www.tryboy.org/archives/1450/ Last modification:December 12, 2022 © Allow specification reprint Support Appreciate the author WeChat Like 0 如果觉得我的文章对你有用,请帮忙点一下上面的广告