2012年1月25日水曜日

sshでパスワードなし接続




次のスクリプトを走らせましょう。
これでうまくいくはず!!!
#!/bin/sh
hosts = "puzzel11 puzzle12 puzzle14 puzzle15 puzzle16 puzzle17 puzzle19 puzzle20 puzzle21 puzzle23 puzzle24"
user = "mame"

ssh-keygen -t rsa
cat ~/.ssh/id_rsa.pub >>~/.ssh/authorized_keys
chmod 700 ~/.ssh
chmod 600 ~/.ssh/*
for host in ${hosts}
do
 ssh ${user}@${host} 'ssh-keygen -t rsa'
 ssh ${user}@${host} 'cat ~/.ssh/id_rsa.pub' |cat ->> ~/.ssh/authorized_keys
done

for host in ${hosts}
do
 scp ~/.ssh/authorized_keys ${host}:~/.ssh
 ssh ${user}@${host} 'chmod 700 ~/.ssh; chmod 600 ~/.ssh/*'
done

exit
うまくいったよー。
このエントリーをはてなブックマークに追加



0 件のコメント :

コメントを投稿