8 April 2009 1:16 PM

I write this post mainly as a reminder, but it might be also usefull for some people.
Requirements : openssh client

Open a terminal and type this command to generate the key pair (private/public) :

ssh-keygen -t dsa -b 1024

You need to answser to two questions :

First, where do you want to save the keys ?
The default (/home/username/.ssh/.id_dsa) is usually a good choice, so just hit Enter here.

Second, what passphrase ?
This passphrase will be asked once per session. You can hit Enter with an empty passphrase, but that means no passphrase : not really a good idea :)

Now we copy the public key on the remote server like this (assuming your remote server hostname is toto.host.org and your remote user on this server is titi) :

ssh-copy-id -i ~/.ssh/id_dsa.pub titi@toto.host.org

Then try to log into the remote server :

ssh titi@toto.host.org

The first time, you'll be prompted for your passphrase. the passphrase won't be asked anymore until you log out/in your session.

Create nifty ssh shorcuts :

To avoid typing the whole user@host.org string you can create shortcuts in ssh config file. Open or create it with gedit like this :

gedit ~/.ssh/config

For each remote server, add a section like this :

Host toto
 Hostname toto.host.org
 User titi

Now, you can log in to your remote server like this :

ssh toto

Completion also work here :

ssh to[TAB] 

2 Responses to “Install public ssh key on a remote server”

  1. tig12 says:

    Das ist gut, impeccable
    rapide à faire, et super pratique
    merci

  2. PianoDraft says:

    PianoDraft…

    [...] Good piano performance. Thanks heaps for this!... if anyone else has anything it would be much appreciated. Great website http://www.en.Grand-Pianos.org Enjoy!...

Leave a Reply

preload preload preload