Public private key based login to Unix computer
We know that we can login to a Unix system in several ways. One drawback with username password mode is that there will be requirement to update the password frequently. In such cases, we go for the public key based login.
Required software
1. Putty and puttygen
Putty can be downloaded from the download page of https://www.putty.org/
The downloaded zip contains both putty and puttygen.
2. Winscp
This is an optional software which gives a window when dealing with ssh, ftp, sftp connections. This can be downloaded from their official site.
How it works
In the public key based login, we will generate a public key and corresponding private key pair. We can optionally protect the private key using a password so that if someone gets your private key, they wont be able to put it into real use [The secret would be needed for loading your private key to the ssh client].
Process
Create the public - private key pair
1. Open puttygen.
2. Click on the 'Generate public/private key pair' - 'Generate' Button.
3.
This will generate the public key in the visible text box.
4. Now, save the public key using the 'Save public key' button.
5. Enter the password and confirm it.
6. Save the private key using the 'Save private key' button.
Now we have a public key, corresponding private key and a password that has be used for making use of the the private key.
Configuring the public key on the Unix server
1. Login to the Unix user for which we are going set the public key login.
2. Go to <user home>/.ssh directory[Create the directory if it does not exist].
3. You may be having a file name 'authorized_keys'. If not , create a file.
4. Paste the public key in the file. If there are some keys saved already, add the new key below them.
5. Save the 'authorized_keys' file.
Logging in with private key
1. Open your ssh client (open putty in this case).
2. Enter the hostname and the port .
3. Go to Connection -> SSH -> Auth . Browse and load the private keys which we saved earlier.
4. Click on Open, a new ssh session will be opened. It will ask for the password for the private key. enter the password and you will be logged onto the Unix machine.
Note : If you are using Winscp, Create a new connection(or site), enter the hostname, click on the 'Advanced' button. This will open a new window. Go to SSH-> Authentication. In the Authentication parameters section, browse and upload the private key file.
That's it. I am keeping things to bare minimum that needs. The rest is something you learn as situation demands.
Comments
Post a Comment