SSH keys are a great way to secure your remote server. By adding a public SSH key to your server, you can easily access it from any computer with an SSH connection. To add a public SSH key to your server, follow these steps:

  1. Log in to your server using the username and password you used when you first set up the server.
  2. In the terminal, type ssh-keygen . This will create a new SSH keypair for your server.
  3. To use the new SSH keypair, type ssh-keygen -t rsa . This will create a new RSA keypair for your server.
  4. To add the newly created RSA keypair to your server, type ssh-keyadd -p 2222 . This will add the newly created RSA keypair to your server’s authorized_keys file.

The first thing you’ll need to do is make sure you’ve run the keygen command to generate the keys:

Then use this command to push the key to the remote server, modifying it to match your server name.