甲骨文 服务器 Oracle Cloud 开启 root 登录
侧边栏壁纸
博主昵称
郭

  • 累计撰写 21 篇文章
  • 累计收到 1 条评论
文章目录

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

Guo
Guo
2023-02-18 / 0 评论 / 9 阅读 / 耗时: 7 ms /

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

你认为这篇文章怎么样?
  • 0
    点赞
  • 0
    踩
  • 0
    酷
  • 0
    滑稽
  • 0
    尴尬
  • 0
    睡觉

评论 (0)

取消