Access a server with an SSH key

Install ssh on the server:

apt-get install openssh-server

Generate a key pair (files id_rsa and id_rsa.pub) with a passphrase:

ssh-keygen

Edit the ssh configuration file:

vi /etc/ssh/sshd_config

In the file, make the following settings:

   PasswordAuthentication no
   PermitRootLogin without-password
   RSAAuthentication yes
   PubkeyAuthentication yes

Add the public key as an authorized key for root that can be used for login:

cat id_rsa.pub >> /root/.ssh/authorized_keys

That’s all for the server!

Now for the client. Copy the key pair into the folder ~/.ssh. Now you should be able to connect with:

ssh -i ~/.ssh/id_rsa root@server

Open SSH folder in Dolphin using a SSH-key

Dolphin allows you to connect to folders on other machines per SSH, but there is no option to specify a key file. But you can add the key to your general SSH configuration (with the added benefit that you also won’t have to specify the keyfile anywhere else, no more -i on the command line!). This is how it works:

  1. Locate your private key file, say it’s ~/.ssh/myidentity_rsa.
  2. Open or create the file ~/.ssh/config and add the lines
    Host myhost.net
      HostName myhost.net
      IdentityFile ~/.ssh/myidentity_rsa
    
  3. Type fish://user@myhost.net/path/to/folder/ into the location bar.
  4. Now it should ask for the passphrase to your key.

Done!