SSH is short for Secure Shell. Secure Shell is a network protocol that provides administrators with a secure way (with encryption) to access a remote computer. it allows an administrator to log into virtual space server with an SSH key instead of a typical password. This eliminates the usual weakness of cracking passwords since SSHs almost can not be deciphered or cracked. So how exactly does this work? Let's find out in this tutorial.
SSH works using a key pair; the public key and the private key. The private key is kept on the computer you log in from, while the public key is stored in the .ssh/authorized_keys file on all the computers you want to log into. The public key stored on the server you wish to unlock and by matching the private pair, you are able to unlock the system. This process is called the Public Key Authentication and as I mentioned earlier, provides more security than a password.
How To Generate SSH Kyes (RSA)?
There are two different forms of SSH key pairs, either the "RSA" (Rivest-Shamir-Adleman) or the "DSA" ("Digital Signature Algorithm") keys. Over the years, the RSA has proven to be more secure and is the only recommended choice for new keys. As a result, SSH and RSA are used interchangeably.
Let us follow the following steps to generate RSA keys -
Generating the Key Pair
We will begin by creating our key pair. This will be done on the client computer or your personal computer. The ssh-keygen utility will be used. Enter the following command in terminal to create the Key pair.
ssh-keygen -t rsa
Store the Keys and Passphrase
You will be prompted for a location to save the keys and provide a passphrase for the keys. This passphrase will protect your private key while it's stored on the hard drive. You may not enter a passphrase but It is advisable that you choose to enter one. This is partly because your key pair is only safe as long as it is unavailable to others. By adding a passphrase to your key pair, people who happen to attain your private key will need to crack your passcode before they can have access to your accounts. The only issue a few have had with the passphrase is the added step of logging into your accounts. Your key files (2) will be created in $HOME/.ssh/ directory if you happen to accept the defaults. Your private key in $HOME/.ssh/id_rsa.pub and your private key in $HOME/.ssh/id_rsa.
Copy the Public Key
The next step is to place the public key on your server so that you can use SSH key authentication to log in. You can transfer your RSA key by entering the following command from your own computer.
Where username and host should be replaced by your username and the name of the computer you're transferring your key to.
Verify SSH is working well
You can make sure this worked by entering the following command in terminal -
A prompt requiring your passphrase will be presented. Enter your passphrase, and provided host is configured to allow key-based logins, you should then be logged in as usual.
I hope this simple tutorial effectively introduces you to Secure Shell also known as SSH and how to generate and use them. Share your thoughts and comments with us in the comments below. Also if you need any help while creating the SSH key, let me know them in the comment section below.
Most Read Articles
Translate Our Site