您好,登錄后才能下訂單哦!
批量實現自動發送公鑰到遠程主機
firewalld:關閉
selinux:關閉
#!/bin/bash
#
#********************************************************************
#Author: hechunping
#QQ: ×××
#Date: 2019-11-07
#FileName: ssh-sshpass.sh
#URL: hexiaoshuai.blog.51cto.com
#Description: The test script
#Copyright (C): 2019 All rights reserved
#********************************************************************
NET=172.20.200
USER=(root hechunping)
PASSWORD=123456
ssh-keygen -t rsa -P '' -f ~/.ssh/id_rsa &> /dev/null
sed -i '/StrictHostKeyChecking/c StrictHostKeyChecking no' /etc/ssh/ssh_config
rpm -q sshpass &> /dev/null || yum -y install sshpass &> /dev/null
for i in {1..254} ; do
{
sshpass -p $PASSWORD ssh-copy-id -i ${USER[0]}@${NET}.${i} &> /dev/null
}&
done
wait
#!/bin/bash
#
#********************************************************************
#Author: hechunping
#QQ: ×××
#Date: 2019-11-07
#FileName: ssh-expect.sh
#URL: hexiaoshuai.blog.51cto.com
#Description: The test script
#Copyright (C): 2019 All rights reserved
#********************************************************************
NET=172.20.200
USER=(root hechunping)
PASSWORD=123456
ssh-keygen -t rsa -P '' -f ~/.ssh/id_rsa &> /dev/null
for i in {1..254} ; do
{
expect <<EOF
spawn ssh-copy-id -i ${USER[0]}@${NET}.${i}
expect {
"yes/no" { send "yes\n";exp_continue }
"password" { send "${PASSWORD}\n" }
}
expect eof
EOF
}&
done
wait
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。