甲骨文VPS Oracle Cloud 开启 root 登录
1.利用 cloud-init脚本来开启root账号密码登录
脚本如下:
#!/bin/bash
echo root:2023dmgls |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默认密码是: 2023dmgls
登录后一定要修改密码!命令:passwd
2.使用密钥登录系统以后
执行如下命令
sudo -i
passwd
按提示刷入密码,重复输入密码。
接着输入
echo root:329105sz |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 restart3、使用密钥登录系统以后
sudo -ivi /root/.ssh/authorized_keys
把ssh-rsa之前的内容都删除掉.vi /etc/ssh/sshd_config
找到PermitRootLogin, 把前面的#去掉
更改为 PermitRootLogin yes
找到PasswordAuthentication
更改为 PasswordAuthentication yes
退出编辑passwd 更改密码reboot 重启vps
所用到的命令;vi 文本编辑器cd 进入目录pwd 查看当前位置ls 查看当前文件夹文件ls -a 查看当前文件夹所有文件vi 编辑器命令i 进入编辑模式esc 回到命令模式:wq 保存并退出
当前页面是本站的「Google AMP」版。查看和发表评论请点击:完整版 »