Viewable by the world
  • Generate SSH Key Pair: If you don't already have an SSH key pair, you can generate one on your local system using the ssh-keygen command. Open a terminal and type the following command.


ssh-keygen -t ed25519 -C "[email protected]"


    • Replace "your_email@example.com" with your email address. Press Enter to accept the default file location and optionally but recommended set a passphrase for added security.
    • Using a passphrase with your SSH key ensures that even if your key were somehow stolen it cannot be utilized without the required passphrase.


  • Copy Public Key to Server: Once the key pair is generated, you'll need to copy the public key to your server. You can use the ssh-copy-id command for this. Replace username and server_ip with your username and server IP address respectively:


ssh-copy-id username@server_ip


    • Alternatively, Manually Add Public Key: If ssh-copy-id is not available, you can manually add the public key to the ~/.ssh/authorized_keys file on your server. You can do this by copying the contents of your local ~/.ssh/id_ed25519.pub file and appending it to the ~/.ssh/authorized_keys file on the server. You can use a text editor like nano or vim to edit the file.
    • Set Correct Permissions: If manually created ensure that the ~/.ssh directory and the ~/.ssh/authorized_keys file on your server has the correct permissions. You can set the permissions using the following commands:


chmod 700 ~/.ssh
chmod 600 ~/.ssh/authorized_keys


  • Test SSH Connection: Finally, test the SSH connection to ensure that public key authentication is working correctly. Open a new terminal window and attempt to SSH into your server.
    • You should be able to log in without your password, if the SSH key was created with a passphrase you will be prompted to enter that to use the key.
  • No labels