3

甲骨文云 服务器 Oracle Cloud 如何启用root登录

 2 years ago
source link: https://vps.la/2022/12/22/%e7%94%b2%e9%aa%a8%e6%96%87%e4%ba%91-%e6%9c%8d%e5%8a%a1%e5%99%a8-oracle-cloud-%e5%a6%82%e4%bd%95%e5%90%af%e7%94%a8root%e7%99%bb%e5%bd%95/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

甲骨文云 服务器 Oracle Cloud 如何启用root登录-VPS啦

Oracle Cloud 开启root 登录

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

#!/bin/bash
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;
sudo service sshd restart

默认密码是: 329105sz
登录后一定要修改密码!命令: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 restart

重启sshd服务

sudo 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

所用到的命令;
vi 文本编辑器
cd 进入目录
pwd 查看当前位置
ls 查看当前文件夹文件
ls -a 查看当前文件夹所有文件
vi 编辑器命令
i 进入编辑模式
esc 回到命令模式
:wq 保存并退出

未经允许不得转载:VPS啦 » 甲骨文云 服务器 Oracle Cloud 如何启用root登录


Recommend

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK