#! /bin/bash ## This script is relevant when setting up a clustered PC that are linked via a switch. ## SSH login without password ## You want to use Linux and OpenSSH to automize your tasks. Therefore you need an automatic login from user a / host A to user b / Host B. You don't want to enter any passwords, because you want to call ssh from a within a shell script. ## The first step is to generate a pair of authentication keys for user a in host A by issuing 'ssh-keygen -t rsa'. ## If 'ssh-keygen -t rsa' has ever been executed by user a, in the directory ~/.ssh of user a you will not find a pair if authentication keys, name respectively as 'id_rsa.pub' and 'id_rsa'. Only when after 'ssh-keygen -t rsa' is executed will these pair of authentication files be found there. ## In order to access host B from host A with username a, the authentication key id_rsa.pub (found in ~/.ssh of user a) has to be appended to host B's ~/.ssh/authorized_keys. ## As a result, In ~/.ssh/ of user a in Host B, you will find a file named authorized_keys, which has the same content as id_rsa.pub in ~/.ssh of user a in Host A. ## The command lines below do just that. This script is to be run on your local PC (e.g., user / host A = tlyoon / 10.0.0.100) so that you can access remotely the intended remote computers remotely in the school of physics, usm. wget http://10.205.19.205/configrepo/howto/linux/ssh-copy-cluster chmod +x ssh-copy-cluster wget http://10.205.19.205/configrepo/howto/linux/ssh-agen chmod +x ssh-agen ssh-keygen -t rsa; ### Warning: When this command line is run, a fresh pair of id_rsa.pub' and 'id_rsa' will be generated if choose 'overwrite' when prompted. ### Overwritting the existing authentication pairs will change these keys. As a result, the previously configured password-free access to remote PC by tlyoon to the remote computers to fail. ### Suggestion: If prompted to overwrite existing keys, safest to choose 'no'. ./ssh-copy-cluster ## In case this script fails to establish a passwordless ssh among the PC, try ./ssh-agen and then ./ssh-copy-cluster again. The files ssh-copy-cluster and ssh-agen will be downloaded automatically to the same folder containing this script when it is executed.