SSH Automatic Login with Public/Private Keys

Firstly, if you are not using SSL for all your sites, you should step it up! NameCheap's SSL certificates start at only $9. There's no excuse!
Firstly, if you have not tried Digital Ocean's SSD Virtual Servers for only $5/mo, I highly recommend them!

Some people like to create ssh keys in addition to entering their password for double security. I am not one of these people – I am sick of typing my damn password.

# Create public and private key files
ssh-keygen -b 1024 -f identity -P '' -t dsa

# Copy it to the server you want to connect to sans password
scp identity.pub user@SERVERNAME:~/identity.pub

# SSH to the server, add new key to authorized_keys
ssh user@SERVERNAME
mkdir .ssh
cat identity.pub >> .ssh/authorized_keys
chmod 400 .ssh/authorized_keys
exit

# Test it out
ssh -i identity user@SERVERNAME


About this entry


Good Reads