#! /bin/bash # Launch this script as $USER in the frontend to configure passwordless ssh to-and-fro the frontend and all nodes in the cluster for the $USER userhome=$(echo $HOME) echo 1 Generate two files, id_rsa and id_rsa.pub, in $HOME/.ssh in the node $(hostname) if [[ -e $userhome/.ssh/id_rsa.pub ]]; then echo "pub rsa exists. Will not creat any."; else ssh-keygen -t rsa; fi /share/apps/local/bin/coc-sshreachable hosts=$(cat /share/tmp/ssh-reachable.dat) for rn in $hosts do echo 2 copy the rsa key of the $user in the current node to the remote node ssh-copy-id -i $userhome/.ssh/id_rsa.pub $rn echo 3 remotely generates the rsa key for the $user in the rn by ssh-ing from the current compute node. ssh -oStrictHostKeyChecking=no $rn "if [[ -e $HOME/.ssh/id_rsa.pub ]]; then echo "pub rsa exists. Will not creat any"; else yes '' | ssh-keygen -t rsa; fi" echo 4 remotely asks the rsa key for the $user in the rn to be copied via ssh to the current compute node. #ssh $USER@$rn "ssh-copy-id -i $HOME/.ssh/id_rsa.pub 192.168.1.10" ssh -oStrictHostKeyChecking=no $rn "ssh-copy-id -i $HOME/.ssh/id_rsa.pub -oStrictHostKeyChecking=no $USER@192.168.1.10" done