1.切換到root賬號
sudo -i
2.設置root密碼
passwd
然後會要求輸入新密碼,然後再重複一次密碼,輸入密碼的時候不會顯示出來,所以直接輸入密碼,然後回車,再然後重複輸入密碼回車
二、開啓SSH權限
①方法一
1.修改SSH配置文件/etc/ssh/sshd_config
vi /etc/ssh/sshd_config
2.然後再輸”i”進入編輯模式
i
3.找到以下內容並修改
PermitRootLogin yes //默認爲no,需要開啓root用戶訪問改爲yes
PasswordAuthentication yes //默認爲no,改爲yes開啓密碼登陸
4.修改完成後,再下按 esc 鍵,然後再輸入
:wq
5.重啓SSH服務
service sshd restart
②方法二
CentOS和Debian通用,輸入以下兩條命令
sed -i 's/PermitRootLogin no/PermitRootLogin yes/g' /etc/ssh/sshd_config
sed -i 's/PasswordAuthentication no/PasswordAuthentication yes/g' /etc/ssh/sshd_config
Ubuntu系統,輸入以下兩條命令
sed -i 's/#PermitRootLogin prohibit-password/PermitRootLogin yes/g' /etc/ssh/sshd_config
sed -i 's/PasswordAuthentication no/PasswordAuthentication yes/g' /etc/ssh/sshd_config
重啓服務器
reboot