SSH – No password

Get your SSH public key – with from IP prepended – ready to add to the authorized_keys file of a server you want to log into without a password.

IP=$(curl -Sfs && KEY=$(cat ~/.ssh/ && echo 'from="'$IP'"' $KEY

Go one step further and add it to the server automatically:

IP=$(curl -Sfs && KEY=$(cat ~/.ssh/ && echo 'from="'$IP'"' $KEY | ssh user@host 'cat >> ~/.ssh/authorized_keys'

2 Replies to “SSH – No password”

  1. I’ve noticed, depending on the server and permissions sometime this doesn’t work and you still need to enter a password..

    Try the following:

    Put the public key in .ssh/authorized_keys2

    mv authorized_keys authorized_keys2

    Change the permissions of .ssh to 700

    chmod 700 .ssh

    Change the permissions of .ssh/authorized_keys2 to 640

    chmod 640 authorized_keys2

Leave a Reply