In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/03 Report--
Expect has non-interactive function
Yum-y install expect
Mkpasswd-l 20 # / dev/null 2 > & 1
10 one-click distribution of public key expect script does not specify a host
Vim fenfa_sshkey.exp
#! / usr/bin/expect
If {$argc! = 2} {
Send_user "usage:expect fenfa_sshkey.exp file host\ n"
Exit
}
# define var
Set file [lindex $argv 0]
Set host [lindex $argv 1]
Set password "123456"
# spawn scp / etc/hosts root@10.0.0.142:/etc/hosts
# spawn scp-P6666 $file jiege1@$host:$dir
Spawn ssh-copy-id-I $file "- p6666 jiege1@$host"
Expect {
"yes/no" {send "yes\ r"; exp_continue}
"* password" {send "$password\ r"}
}
Expect eof
Exit-onexit {
Send_user "jiege say good bye to you!\ n"
}
Expect fenfa_sshkey.exp .ssh / id_dsa.pub 192.168.169.11
# you need to enter the public key and ip manually, but you don't have to enter the yes and password manually (expect non-interactive function). You can write fenfa_sshkey.exp to the script with one click to log in the cluster through the master server ssh.
Write to multiple hosts in batch
Vim fenfa_sshkey.sh
#! / bin/sh
. / etc/init.d/functions
For ip in 11 12 13 14 15
Do
Expect fenfa_sshkey.exp ~ / .ssh/id_dsa.pub 192.168.169.$ip > / dev/null 2 > & 1
If [$?-eq 0]; then
Action "$ip" / bin/true
Else
Action "$ip" / bin/false
Fi
Done
Note that this script should be in the same directory as fenfa_sshkey.exp
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.