You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
15 lines
654 B
15 lines
654 B
#!/bin/bash
|
|
|
|
###通过配置 nopass.config ,实现与多服务器的免密登录
|
|
|
|
[ ! -f $HOME/.ssh/id_rsa ] && ssh-keygen -t rsa -b 2048 -N "" -f $HOME/.ssh/id_rsa
|
|
if ! grep -Ff $HOME/.ssh/id_rsa.pub $HOME/.ssh/authorized_keys &>/dev/null; then
|
|
cat $HOME/.ssh/id_rsa.pub >>$HOME/.ssh/authorized_keys
|
|
fi
|
|
chmod 600 $HOME/.ssh/authorized_keys
|
|
|
|
for ip in $(awk '/^[0-9]/{print $1}' nopass.config | sort -u); do
|
|
# ssh-copy-id -o StrictHostKeyChecking=no -o CheckHostIP=no root@$ip
|
|
rsync -a $HOME/.ssh/id_rsa* $HOME/.ssh/authorized_keys -e 'ssh -p 2009 -o StrictHostKeyChecking=no -o CheckHostIP=no' mmog@$ip:/home/mmog/.ssh/
|
|
let ret+=$?
|
|
done
|
|
|