gcp_root_ssh.sh 693 B

1234567891011121314151617181920
  1. #!/bin/bash
  2. # Google Cloud Platform GCP实例开启密码与root用户登陆
  3. # GCP一键启用root帐号命令
  4. # wget -qO- git.io/fpQWf | bash
  5. # GCP 启用root密码登陆
  6. sed -i "s/PermitRootLogin.*/PermitRootLogin yes/g" /etc/ssh/sshd_config
  7. sed -i "s/PasswordAuthentication.*/PasswordAuthentication yes/g" /etc/ssh/sshd_config
  8. # 重启ssh服务
  9. systemctl restart ssh
  10. #定义文字颜色
  11. Green="\033[32m" && Red="\033[31m" && GreenBG="\033[42;37m" && RedBG="\033[41;37m" && Font="\033[0m"
  12. # 修改root 密码: bash脚本不能直接运行passwd,用户手工使用命令
  13. echo -e "${Red}请手工输入命令${GreenBG} passwd ${Green}修改root用户的密码! ${Font}"
  14. echo