December 19, 2008

Set up ssh key pairs


With ssh key pairs you can easier login to your servers.

To generate an ssh key pair you´ll need to run the following line in your terminal:

ssh-keygen -t dsa

It will ask you for location and pass phrase. You should accept the default location (~/.ssh/ For the pass phrase I usually just press return. Then the private key will have a blank pass phrase and you can login to your servers without a password. Comfort vs. security. Your choice.

After this you need to upload the public key to the server.

scp ~/.ssh/

Finally login to the server and append the public key to authorized keys:

mkdir .ssh          # if it's not already there
cat >> .ssh/authorized_keys
rm       # cleanup

Make sure that the .ssh folder and the authorized_keys have the right permissions:

chmod 700 ~/.ssh
chmod 600 ~/.ssh/authorized_keys

After this, you should be able to login to the server and use scp without having to enter a password.

If you login or copy files to your servers a lot, you can setup an alias in ~/.ssh/config (on your local machine):

Host ys
User you


Linux, scp, ssh, sshkeypairs

You may also like

Leave a Reply

Your email address will not be published. Required fields are marked

Information about Data protection

This site uses Akismet to reduce spam. Learn how your comment data is processed.

{"email":"Email address invalid","url":"Website address invalid","required":"Required field missing"}