How to setup SSH-Key Authentification

The most current version as of .

First you have to generate a new key pair with the ssh-keygen command.

You will get a file without a suffix (this is your private key) and a file with the .pub suffix (this is your public key).

For the remote server to accept incoming ssh logins from your ssh-client, make sure to copy over your public key to the remote server using either the ssh-copy-id command or the web interface, if your service provider has one, to add your public key.

On the server your public key will be added to the ~/.ssh/authorized_keys file.

Next up you can add your newly generated key into your SSH configuration file ~/.ssh/config by linking its file path on your local filesystem to the IdentityFile option under your connection details.

Host example
    User example
    HostName example.org
    IdentityFile ~/.ssh/example

Once finished configuration you can type ssh example to connect to your server specified in the HostName option using the username under the User option and your private ssh key.

— David Wolf