Moreover, SSH can establish an encrypted channel for the communication between client and server on an unsecured network. Hence, it is important to generate SSH keys. But many newbies do not know how to do it. So, this tutorial will briefly describe the methods to generate SSH keys on Pop!_OS.
How to Generate SSH Keys on Pop!_OS
To generate an SSH key, open the terminal and execute the following command:
The above command will generate an SSH key of 3072-bit RSA key pair. But if you want to go one step further, execute the following:
The -b 4096 with the ssh-keygen creates the 4096-bit key. Moreover, we have used RSA in the above, but you can also use the following algorithms:
|Rivest Shamir Adleman
|Key with a minimum size of 2048 based on the difficulty.
|Digital Signature Algorithm
|This key is used with the 1024 size.
|Elliptic Curves Digital
|This key is used to support the 256, 384, and 521 bits.
The system will ask you to provide the file’s name after executing the command.
You can either press the Enter button to generate a key in the default file or type the file name accordingly. Finally, generate the SSH key passphrase to finalize everything. This passphrase gives an extra layer of protection and security to prevent unauthorized user access.
Now, copy the public key so you can use the ssh-copy-id. So, you can use the command given below to copy the key:
Add your system name from the username and <SERVER IP_ADDRESS> with the host’s IP address.
After that, it will scan the local account and the key you have created and then prompt you to enter the password of the remote user account.
In some cases, the terminal shows an error while copying the public key so you can use the following commands to copy the public key using SSH:
Suppose everything goes well with the above commands, type yes and press the Enter button to continue. Next, you must enter the server account’s password and press the Enter button to complete the process.
Now, you can log in to the remote server by using the command given below:
Once you run the command, enter the passphrase to access the server or you may get logged out of the server.
If you want to disable password authentication, log in to the remote server with admin privileges. Now, execute the following command to open the /etc/ssh/sshd_config:
In the config file, set the PasswordAuthentication from yes to no. Then, save the file. Finally, restart the SSH service through this command:
With a successful restart, the system will close all the current sessions and implement all the changes.
So, this was about the easiest way to generate SSH keys on Pop!_OS. Generating SSH keys can be confusing if you do not use the command correctly. Sometimes users face issues while copying the host’s IP in their SSH key, so verify the host’s IP before copying it.