#! /bin/bash ##### $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ ## Run this script in a current node by defining the user and the IP of the remote server ## This will generate a passwordless ssh for $user to-and-fro the current node and the frontend ## Need to supply password to and fro both nodes when prompted ##### $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ user=root frontend=192.168.1.10 ######### do not need to modify ####### ### generates a rsa key in the current compute node for $user ssh-keygen -t rsa ### copy the rsa key of the $user in the current compute node to the frontend ssh-copy-id -i $user/.ssh/id_rsa.pub $frontend ### remotely generates the rsa key for the $user in the frontend by ssh-ing from the current compute node. ssh $user@$frontend "ssh-keygen -t rsa" ### remotely asks the rsa key for the $user in the frontend to be copied via ssh to the current compute node. HOSTNAME=$(cat /etc/hostname) ssh $user@$frontend "ssh-copy-id -i $user/.ssh/id_rsa.pub $HOSTNAME"