Занесем список всех серверов в файл:
$ vim server.list
server1.ru
server2.ru
192.168.0.100
192.168.0.101
...
Установим sshpass чтобы постоянно руками не вводить пароль:
# apt-get install sshpass
Маленький скрипт, который будет раскидывать ключи:
$ vim script.sh
#!/bin/bash
while read -r line
do
echo "running $line"
sshpass -p пароль ssh-copy-id имя_пользователя@$line -o "StrictHostKeyChecking no"
done < "server.list"
Запускам скрипт:
$ sh script.sh
running server1.ru
/usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed
/usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys
Number of key(s) added: 1
$ vim server.list
server1.ru
server2.ru
192.168.0.100
192.168.0.101
...
Установим sshpass чтобы постоянно руками не вводить пароль:
# apt-get install sshpass
Маленький скрипт, который будет раскидывать ключи:
$ vim script.sh
#!/bin/bash
while read -r line
do
echo "running $line"
sshpass -p пароль ssh-copy-id имя_пользователя@$line -o "StrictHostKeyChecking no"
done < "server.list"
Запускам скрипт:
$ sh script.sh
running server1.ru
/usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed
/usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys
Number of key(s) added: 1
running server2.ru
/usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed
/usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys
Number of key(s) added: 1
/usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed
/usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys
Number of key(s) added: 1
Комментариев нет:
Отправить комментарий