最近很多撸GCP的,有的人不会改root登录,找到份教程分享给大家顺便给自己存个档
放心用!纯指令没有调用任何脚本,完全不用担心安全问题也不需要用任何脚本,像我这种用个别人的脚本都要下下来丢给ai查一遍有没有后门的人用这种最安心了
在打开的网页版ssh登录界面,依次输入以下命令(复制以下命令,然后Ctrl+v 粘贴):
sudo sed -i 's/PermitRootLogin /#PermitRootLogin /g' /etc/ssh/sshd_config
sudo sed -i 's/PasswordAuthentication /#PasswordAuthentication /g' /etc/ssh/sshd_config
sudo sed -i 's/PermitEmptyPasswords /#PermitEmptyPasswords /g' /etc/ssh/sshd_config
echo "PermitRootLogin yes" | sudo tee -a /etc/ssh/sshd_config
echo "PasswordAuthentication yes" | sudo tee -a /etc/ssh/sshd_config
echo "PermitEmptyPasswords no" | sudo tee -a /etc/ssh/sshd_config
sudo systemctl restart sshd
生成随机密码:
cat /dev/urandom | tr -dc '_A-Z#-+=a-z(0-9%^>)]{<|' | head -c 20 ; echo ''
sudo passwd root
输入两次上面生成的随机密码,这个随机密码要保存好。这个就是登录root账户的密码。
原文来自:谷歌云开启root账户与密码登录
本文链接:https://www.vpszhuji.com/453.html,转载请注明出处。