Suppose the hostname of five client nodes are compute-1, compute-2, compute-3, compute-4, and compute-5.
Step 1. Create the authentocation key on Remote SSH for accessing to client or computing node.
Use ssh-keygen to generate authentication key.
ssh-keygenThen you are asked to set where you want to save the key files. Just Enter to use default setting.
Generating public/private rsa key pair.Enter file in which to save the key (/home/rangsiman/.ssh/id_rsa):Enter passphrase (empty for no passphrase):Enter same passphrase again:Enter three times to use default value. Then you will get the warning message. Now it's finished.
The key fingerprint is:--------------------------------------------------- rangsiman@RemoteSSHThe key's randomart image is:+--[ RSA 2048]----+| .==. E || o.o.* = ||. o = = || + o . + || + + S || o o . || . || || |+-----------------+Look at $HOME/.ssh/. There you should have id_ras and id_ras.pub files. Now, copy id_ras.pub to authorized_keys file.
cp id_ras.pub authorized_keysStep 2. Create automatic script to send token authentication key to all clients.
On Remote SSH, create new bash script and copy/paste following code to bash script.
cd $HOME/.sshfor i in compute-{1..5}doscp -r id_ras id_rsa.pub authorized_keys $USER@$i:$HOME/.ssh/doneStep 3. Run script
Change permission of script using
chmod +x bash_script.shYou also must change the hostname of client before run the script !
Then run script
./bash_script.shFiles specified in scp line will be sent to compute-1, compute-2, compute-3, compute-4, and compute-5.
When it's done, you are able to access to client using SSH passwordless.
Rangsiman Ketkaew