How to use dsh and password-less ssh in-between the nodes

It's very easy to get password-less ssh working in-between the nodes, you just need a proper ssh-keypair in your home.

This script will take the necessary steps, but you can do it manually (see below):
#!/bin/sh

if [ -s $HOME/.ssh/authorized_keys ];then
        echo "You have already a ~/.ssh/authorized_keys"
        echo "call ssh-keygen manually and"
        echo "cat ~/.ssh/ide_rsa.pub >> ~/.ssh/authorized_keys"
        exit 0
fi
if [ -s $HOME/.ssh/id_rsa ];then
        echo "You have already a keypair"
        echo "rm ~/.ssh/id_rsa  ~/.ssh/id_rsa.pub"
        echo "try it again"
        echo "or /usr/bin/ssh-keygen -f \"another name\""
        exit 0
fi

/usr/bin/ssh-keygen -N '' -f $HOME/.ssh/id_rsa
cat $HOME/.ssh/id_rsa.pub >> $HOME/.ssh/authorized_keys
mkdir -p /work/$USER/.ssh
cp $HOME/.ssh/authorized_keys /work/$USER/.ssh/.

Manual approach - if you are sure you don't already have a keypair or would lke to overwrite it:
/usr/bin/ssh-keygen -N '' -f $HOME/.ssh/id_rsa
cat $HOME/.ssh/id_rsa.pub >> $HOME/.ssh/authorized_keys
mkdir -p /work/$USER/.ssh
cp $HOME/.ssh/authorized_keys /work/$USER/.ssh/.

When this works (i.e. ssh a0304 should work without asking for a password) you can also start using dsh, e.g. try running dsh -aMF25 uptime and this should loop over all nodes running the uptime command there.

DocumentationForm edit

Title Passwordless ssh within the local atlas network
Description Passwords can be cumbersome when logging in into individual compute nodes or running dsh
Tags ssh
Category User
Topic revision: r4 - 12 Mar 2020, HenningFehrmann
This site is powered by FoswikiCopyright © by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding Foswiki? Send feedback