1.设置PermitRootLogin yes
sudo vim /etc/ssh/sshd_config
设置PermitRootLogin yes
2.启动SSH服务网
sudo service ssh restart
3.验证SSH是否启动成功
sudo ps -ef | grep ssh
4.设置为开机自动启动
sudo systemctl enable ssh
一键脚本
if [ -f /etc/ssh/sshd_config ]; then
sudo tee /etc/ssh/sshd_config <<< "PermitRootLogin yes"
sudo systemctl restart ssh
else
echo "SSH service is not installed."
exit 1
fi