? Earlier 1 items total Later ?

On this page:?

Bash function to copy SSH DSA public key to a new server

Or, "How to login over SSH without a password".

First of all, you'll need to have generated an SSH public DSA key using the following commands:

cd ~ && ssh-keygen -t dsa


Then, you can add the following bash function to your .bashrc (or similar) and just type 'scpdsa user@hostname' to add your public key to your 'authorized_keys' file on the server.

function scpdsa {
        if [ ! -n "$1" ];
        then
                echo "!! You need to enter a hostname in order to send your public key !!" 
        else
                echo "* Copying SSH public key to server..." 
                scp ~/.ssh/id_dsa.pub $1:~/id_dsa_temp.pub
                echo "* Adding SSH public key to 'authorized_keys' on server..."
                ssh $1 'cat ~/id_dsa_temp.pub >> ~/.ssh/authorized_keys'
                echo "* Removing temporary files from server..."
                ssh $1 'rm ~/id_dsa_temp.pub'
                echo "* All done!"
        fi
}

? Earlier 1 items total Later ?