How To Set up SSH Keys on a Linux / Unix System

Setting up SSH keys is a secure way to log into a remote Linux/Unix system without entering a password. Here’s how to set up SSH keys on a Linux/Unix system:

  1. Generate a key pair: Open a terminal and run the following command to generate a new SSH key pair:
ssh-keygen -t rsa -b 4096

You will be prompted to specify a file to save the key, or you can press Enter to accept the default file. You will also be prompted to enter a passphrase to secure the key, but this is optional.

  1. Copy the public key to the remote system: To log into the remote system without a password, you need to copy your public key to the remote system. Run the following command to copy the public key to the remote system:
ssh-copy-id user@remote_system

Replace user with your username on the remote system and remote_system with the hostname or IP address of the remote system. You will be prompted for the password of the user on the remote system.

  1. Test the setup: To test the setup, log into the remote system using the following command:
ssh user@remote_system

You should be able to log into the remote system without entering a password.

Note: Make sure to keep the private key secure and protected, as it is used to log into the remote system. If the private key is compromised, you should regenerate the key pair.

Leave a Comment