CentOS6、CentOS7、Ubuntu 一键部署 ssh 免密登录(ssh.py 文件)
192.168.1.5 为主机器,其他为控制机。vim /home/shad.pyfrom fabric.api import run,env,parallelenv.hosts = [‘192.168.1.1‘, ‘192.168.1.2‘, ‘192.168.1.3‘]env.user = ‘root‘env.parssword = ‘123456‘#@paralleldef name(): run(‘apt install -y wget || yum install -y wget‘) run(‘wget http://192.168.1.5/ssh.sh‘) run(‘sh shad.sh‘)
CentOS6、CentOS7、Ubuntu 一键部署 ssh 免密登录(ssh.py 文件)vim /var/www/html/ssh.sh
#!/bin/bashname= ' awk ' nr==1{print $ '/etc/issue ' if ["$name" = "Ubuntu"];thensed-i ' [email protected]#[email& Nbsp;protected]@g '/etc/ssh/sshd_configmkdir-p ~/.sshcat >>~/.ssh/authorized_keys<<eof** public key **eofsed-i ' [email protected] #PasswordAuthentication [email protected] [email protected] '/etc/ssh/sshd_ Configservice sshd restartelif ["$name" = "CentOS"];thensed-i ' [email protected] #PermitRootLogin [email protected] [email protected] '/etc/ssh/sshd_configsed-i ' [email protected]#[email protected]@g '/ Etc/ssh/sshd_configsed-i ' [email protected]#[email protected]@g '/etc/ssh/sshd_configsed-i ' [email protected]#[email protected]@g '/etc/ssh/sshd_configmkdir-p ~/.sshcat >>~/.ssh/authorized_keys <<eof** public Key **eofsed-i ' [email protected] [email protected] [email protected] '/etc/ssh/sshd_ Configservice sshd restartelsesed-i ' [email protected] #PermitRootLogin [Email protecTed] [email protected] '/etc/ssh/sshd_configsed-i ' [email protected]#[email protected]@g '/etc/ssh/ Sshd_configmkdir-p ~/.sshcat >>~/.ssh/authorized_keys<<eof Public key Eofsed-i ' [email protected] [email protected] [email protected] '/etc/ssh/sshd_configservice sshd Restartfi
CentOS6, CentOS7, Ubuntu One-click deployment ssh password-free login