分发:
A:
ssh-keygen (以rsa来生成秘钥 或者加上 -t dsa 以dsa生成)
一路回车
ssh-copy-id -i.ssh/id_rsa.pub **@B ssh-copy-id -i.ssh/id_rsa.pub **@C
完成后可以验证下
ssh **@B free-m ssh **@C free-m
备份:
Z:
ssh-copy-id -i .ssh/id_rsa.pub root@Z (自己给自己发 也可以将id_rsa.pub mv改名为authorized_keys 但是前者可以直接修改权限权限600)
scp .ssh/id_rsa **@X:/home/**/.ssh/(将私钥发过去) scp .ssh/id_rsa **@Y:/home/**/.ssh/(将私钥发过去)
可以在XY检测:
ssh **@Z free -m
批量分发:
A:
vim fenfa.sh #!/bin/sh . /etc/init.d/functions if [ $# -ne 1 ];then echo "sh $0 arg0" exit 1 fi for ip in B C do scp -r -p $1 **@$ip:~ >/dev/null 2>$1 #拷目录和保持属性 if [ $? -eq 0 ];then action "scp is ok" /bin/true else action "scp is no" /bin/false done
touch test.log sh fenfa.sh test.log
批量管理:
A:
vim view.sh #!/bin/sh . /etc/init.d/functions if [ $# -ne 1 ];then echo "sh $0 arg0" exit 1 fi for ip in B C do echo "=====start=====" ssh **@$ip $1 echo "=====end=====" done
sh view.sh "free -m"