Published: 2022-09-10

To login to your server(s), it's best to use SSH keys since they are more secure than traditional password authentication. If you're on Linux, things couldn't be easier. Make a new SSH key either yourself or via the web interface of your favourite cloud provider.

Next, add the key to the server(s) that you want to connect to and set the right file permissions on your local system:

$ chmod 700 ~/.ssh/
$ chmod 600 ~/.ssh/*
$ chmod 644 ~/.ssh/*.pub

Also, store the key in your password manager to avoid losing access to your server and add the key to ~/.ssh.

To make it easy to use the key, add the following in to ~/.ssh/config:

Host myserver
    HostName <ip of the server>
    User <root or other user>
    IdentityFile ~/.ssh/<name of your private key>

Now, you can connect to your server by typing:

$ ssh myserver

So, no need to copy past the IP address! It's all in the config.

If you are at an unstable connection and have a not so smooth experience, then take a look at mosh. Instead of crashing when the connection drops, mosh will keep alive and show updates as soon as the connection is back.

To use mosh, install it on the server and your pc:

$ apt install mosh

Then, mosh can be used as a drop-in replacement for ssh:

$ mosh myserver
The text is licensed under CC BY-NC-SA 4.0 and the code under Unlicense.