

近日 OVHCloud 发布了一些廉价服务器促销,站长手痒也购买了一台,OVH独立服务器Linux系统是无法直接使用root登录的,如Ubuntu需要使用ubuntu用户,rocky Linux需要使用rocky用户进行登录。下面站长总结了一下开启root用户的步骤。
1、通过ssh客户端登录系统
2、切换至 root用户
sudo su
3、修改 /etc/ssh/sshd_config
vi /etc/ssh/sshd_config
- 找到
#PermitRootLogin
开头这行(前面可能没有#号),改为PermitRootLogin yes
- 找到
#PasswordAuthentication
开头这行(前面可能没有#号),改为PasswordAuthentication yes
修改好之后保存
4、删除 50-cloud-init.conf
rm -f /etc/ssh/sshd_config.d/50-cloud-init.conf
5、删除默认 /root/.ssh/authorized_keys
rm -f /root/.ssh/authorized_keys
6、创建 root 用户密码
passwd root
输入两次一样的密码,建议密码包含大小写字母和特殊符号,以增强安全性
7、重启 sshd 服务
systemctl restart sshd
结语
教程到此结束。