Skip to main content

Config

To start with, SSH is simple: just ssh username@server and type in your password, and you're on the server's commandline.

To improve security a lot, you'll want to use keypairs - it's a bit more advanced but still straightforward:
- generate a keypair with ssh-keygen, accept the defaults
- copy the public key to the authorized_hosts file on the server - the tool ssh-copy-id can do this for you
- then log into the server with the same command ssh username@server, it should use the key instead of ask for a password.

Basic Config

When dealing with multiple servers, multiple users, multiple keypairs and maybe even a jumphost/bastion for security, it'll be annoying to type out the entire ssh command at some point (example: ssh -p 2222 -i ~/.ssh/id_workkey username2@server3 )

Especially if your DNS is not perfectly set up for ssh, you might also have to type hostnames as server3.work.domain.

To make this easier, you can do SSH config entries in ~/.ssh/config like so:

Host myserver
  HostName server3.work.domain
  User myworkuser
  IdentityFile ~/.ssh/id_workkey

So when you type "ssh myserver" it actually uses these settings configured in ssh config.

If you have a jumphost, you'll also want to use the ProxyJump option, for example:
Host bastion
  HostName bastion.work.domain
  User myworkuser

Host myserver
  HostName myserver.work.domain
  User myworkuser
  ProxyJump bastion

Advanced Config