1. 先选择从浏览器打开 ssh 连接服务器
2. 切换到 root 账号
bash
sudo -i
3. 设置 root 密码
bash
passwd
然后会要求输入新密码,然后再重复一次密码,输入密码的时候不会显示出来,所以直接输入密码,然后回车,再然后重复输入密码回车
①方法一
1. 修改 SSH 配置文件 / etc/ssh/sshd_config
bash
vi /etc/ssh/sshd_config
2. 然后再输”i” 进入编辑模式
bash
i
3. 找到以下内容并修改
bash
PermitRootLogin yes //默认为no,需要开启root用户访问改为yes
PasswordAuthentication yes //默认为no,改为yes开启密码登陆
4. 修改完成后,再下按 esc 键,然后再输入
bash
:wq
5. 重启 SSH 服务
bash
service sshd restart
②方法二
CentOS 和 Debian 通用,输入以下两条命令
bash
sed -i 's/PermitRootLogin no/PermitRootLogin yes/g' /etc/ssh/sshd_config
bash
sed -i 's/PasswordAuthentication no/PasswordAuthentication yes/g' /etc/ssh/sshd_config
Ubuntu 系统,输入以下两条命令
bash
sed -i 's/#PermitRootLogin prohibit-password/PermitRootLogin yes/g' /etc/ssh/sshd_config
bash
sed -i 's/PasswordAuthentication no/PasswordAuthentication yes/g' /etc/ssh/sshd_config
重启服务器
bash
reboot