甲骨文 服务器 Oracle Cloud 开启 root 登录

1.利用 cloud-init脚本来开启root账号密码登录

!/bin/bash

echo root:11235879 |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
默认密码是: 11235879
登录后一定要修改密码!命令:passwd

2.使用密钥登录系统以后,执行如下命令

sudo -i
passwd
按提示刷入密码,重复输入密码。
接着输入

echo root:11235879 |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;
service sshd restart
3、使用密钥登录系统以后

sudo -i
vi /root/.ssh/authorized_keys
把ssh-rsa之前的内容都删除掉.

vi /etc/ssh/sshd_config
找到PermitRootLogin, 把前面的#去掉
更改为 PermitRootLogin yes
找到PasswordAuthentication
更改为 PasswordAuthentication yes
退出编辑
passwd 更改密码
reboot 重启vps

我来吐槽

*

*