A simple script to create sshd_key_file & sync to ohter servers

Sometimes you want to ssh to other servers without input its password, then this script might be useful : )

First of all you need to create a file named "server_list" at /root/, like:

[root@lvs01 ~]# cat server_list 

192.168.1.129   lvs01

192.168.1.130   lvs02

192.168.1.131   web01

192.168.1.132   web02

...

 

here is the script:

cd /root/.ssh/

echo "please keeping press enter :) "

ssh-keygen -t rsa

cat id_rsa.pub >> authorized_keys 

echo "=============sync the authorized_keys file=============="

for i in `cat /root/server_list | grep -v "#" | awk '{print $1}'`; do

echo "please enter $i's password: "

scp /root/.ssh/authorized_keys root@$i:/root/.ssh/

done

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章