How to create SSH keys
SSH (Secure Shell) is a cryptographic network protocol used to securely access and manage remote systems over an unsecured network. It provides a secure channel through which users can log into remote machines, execute commands, transfer files, and perform administrative tasks, all while ensuring confidentiality and integrity of data. SSH uses strong encryption algorithms like AES and public-key cryptography to authenticate users and encrypt the communication between clients and servers. It is widely used by system administrators and developers for remote management of servers, network devices, and other systems, providing a safer alternative to older protocols like Telnet and FTP, which transmit data in plaintext.
To create ssh key pairs in a Linux system follow these steps:
- Open a terminal window and run ssh-keygen. This command will create a default SSH key pair using the RSA algorithm with a key length of 2048 bits.
- After running the command you'll see the following prompt:
- Next, you will be asked to enter a passphrase:
- Once complete, you should see the following confirmation:
- Done! Now you have generated a ssh key pair.
Using the ssh-copy-id utility you can add your ssh public key to a remote server.
- To add the public key to a remote server, use the command: ssh-copy-id user@remote_server_ip
- After entering this command, you’ll be prompted to enter the password for the remote server. Once authenticated, your public key will be added to the ~/.ssh/authorized_keys file on the remote server.
- You can now connect to the server without using a password by typing: ssh user@remote_server_ip
For Windows systems it's reccomended to use a third party program called PuTTY. You can download it from their official website here.
- Download the PuTTY Installer for your system (32-bit or 64-bit) and run the installer.
- During installation, make sure to select both PuTTY and PuTTYgen tools.
- Open the PuTTYgen application and click on Generate.

4. Move your mouse cursor around the blank area in the PuTTYgen window to generate randomness. This helps in creating a unique key pair.
5. Once the key is generated, it will be displayed in the PuTTYgen window.
- Click on Save private key. You will be promted to enter a passphrase. This is optional but reccommended for added security.
- Chose a secure location to save your private key file.
- Click on Save Public key.
- Choose a location to save your public key file.
- Log in with username and password to your remote server using PuTTY.
- Once logged in, open or create the ~/.ssh/authorized_keys file on the remote server:
- Paste the public key that you copied earlier into the authorized_keys file.
- Save and close the file. Ensure that the permissions are set correctly:
- Now you are able to connect to the server without using a password.