Guide for setting up OpenSSH on deb/ubuntu or Arch-based distros.
Install OpenSSH server
Ensure on the server OpenSSH is installed. If not you can install for deb/ubuntu with:
or Arch based distros with:
You'll likely need to change several settings for OpenSSH. First, it's worth first backing up the ssh_config file.
Ensure you disable PasswordAuthentication so users can only SSH in with private keys.
Once configuration is done, restart ssh:
You can generate a keypair by from your linux client with:
To generate a ssh key using the RSA algorithm (older, well-used with wide support):
To generate an ssh key using ED25519 (newer, recommended):
You can then copy and append the client-generated public key (*.pub) to the open ssh server. Or more specifically, to a server user's "
The client should now be able to connect via SSH to the openssh server.
Generating a (new) separate key and using it for a specific host
You might want to use a separate key for a specific host. For example, let's create a key called gitlab_jaytaala for use with in pushing/pulling to/from gitlab.jaytaala.com:
To get your machine to use this key for a specific host (for example from the terminal) we create an the following
config file within your
and add the following:
You can add another section as above for other hosts. Note that indentation is not required (but does make it much easier to read given lots of Host directives).
In the above example, having defined the host
gitlab_jay we can then simply do:
to connect by ssh to host