#!/bin/bash # BY kerryhu # MAIL:[email protected] # BLOG:http://kerry.blog.51cto.com # Please manual operation yum of before Operation. ....
First, establish a trust relationship 192.168.9.203 for the management machine 192.168.9.201 192.168.9.202 for the remote Linux server 1, generate a certificate in the management machine, [root@manage ~]# ssh-keygen -t rsa Generating Enter/express saf key. /id_rsa. (Private Key) Your public key has been saved in /root/.ssh/id_rsa.pub. (public key) The key fingerprint is: 36:ec:fc:db:b0:7f:81:7e:d0 :1d:36:5e:29:dd:5b:a0 2. Transfer the public key on the management machine to each remote server. If the remote server changes the default ssh port number, use scp -P 17173, 17173 as the port number. ,null,null,3],Root@manage .ssh]# scp id_rsa.pub 192.168.9.201:/root/.ssh/authorized_keys [root@ma Nage .ssh]# scp id_rsa.pub 192.168.9.202:/root/.ssh/authorized_keys The trust relationship between the management machine and the remote host is established. 2. Modify the remote server password in batches through the shell script. If you want to call mkpasswd, you must install expect, use mkpasswd. Passwords can be randomly generated usage: mkpasswd [args] [user] where arguments are: -l # (length of password, default = 10) -d # (min # of digits, default = 2) -c # (min # of lowercase Chars, default = 2) -C # (min # of uppercase chars, default = 2) -s # (min # of special chars, default = 1) -v (verbose, show passwd interaction) -p prog (program to set Password, default = passwd) For example, if you want to specify a password with a length of 8 and at least three uppercase letters, you can type: mkpasswd -l 8 - C 3, well, the password will be randomly generated according to your requirements. Yum -y install expect ip_list.txt is the remote server IP list [root@manage .ssh]# cat ip_list.txt 192.168.9.201 192.168.9.202 If the remote service The server modified the default ssh port number, using ssh -p 17173, 17173 for the port number #!/bin/bash #============== Though ssh remote server , auto modify ROOT Passwd =============# for IP in `cat /root/ip_list.txt` #import remote to modify the host's IP do #============= ============ Create Remote Host Password ==================================================================================================== -C 3` R_PWD=`echo ${IP}_${TMP_PWD}` echo "${IP}_${TMP_PWD}" > R_PWD.txt #============ =============== Modify Remote Host Password ================================= If [ $? = 0 ] ; then ssh $IP passwd root --stdin < R_PWD.txt echo -e "$(date "+%Y-%m-%d %H:%M:%S")\\t${IP }\\t${R_PWD}\\t" >> R_Server.log else echo -e "$(date "+%Y-%m-%d %H:%M:%S")\\t$ {IP} R_PWD.txt is create fail\\tplease check!\\t" >> M_pass.log fi if [ $? = 0 ] ; then echo -e "$(date "+%Y-%m- %d %H:%M:%S")\\tThe ${IP} passwd is modify OK\\t" >> M_pass.log else echo -e "$(date "+%Y-%m-%d %H:%M:%S")\\tThe ${IP} passwd is modify fail\\tplease check!\\t" >> M_pass.log Fi done
In order to improve the performance of the server, many network administrators ha
Increasingly junk spam has become a cancer on the Internet. Although most email a
Understand what is the permanent redirection of resources. Under the simple unders
The rapid development of the enterprise network has made the supporting servers an
Five Misunderstandings in Blade Server Technology
VPS installation ZendOptimizer error: Failed loading /usr/local/Zend/lib/Optimizer
Automatically generate "aspnet
Restore Win2000/XP administrator password
Intel's six-core and eight-core server CPU architecture analysis
How to check the IIS concurrent connection number tips
Make web server log files more secure
Getting Started: Understanding Server-Related Parameters
Add downloadable file types in IIS6
Five server-based issues that must be understood
How to increase the maximum number of Apache connections? Details of
Restore the Windows 7 Quick Launch Bar library to Explorer
Win10 system broadband connection error 676 response method
Win10 cancels the quick access feature
How to quickly access Win10 to the specified directory or folder
What should I do if the Windows 8 system C disk space is smaller?
Let Windows 8 start screen wallpaper/magnetic stickers change to
How to open the win10wifi hotspot
How to skip the installation key step in Win8/Win8.1? Win8 skip installation key step method