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] 
Tagged with:  

1 Response » to “Install public ssh key on a remote server”

  1. tig12 says:

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

Leave a Reply

Weboy

Looking for something?

Use the form below to search the site:

Still not finding what you're looking for? Drop a comment on a post or contact us so we can take care of it!