Public-key authentication is a proven, it’s better then allowing password authentication.As long as you keep your private key file safe, you’re less likely to encounter a break-in of your Unix/Linux servers. In this tutorial, I’ll try to show you the steps that you need to create public/private key using SecureCRT and use it with Ubuntu Server.
To create a public/private key pair in SecureCRT, open up SecureCRT, click on “Quick Connect“, from there click on the “Properties“:
Note: Uncheck all other options
Click “Create Identity File…” and the key generation wizard starts:
Click “Next” to get started:
Select RSA as the Key Type and click “Next“:
Next, you are prompted to enter a passphrase twice (I leave it blank, but you should use something pretty long phrase, that you’re going to remember):
Next, it will ask you for your desired key length in bits. Take the default “1024” and click “Next“:
Now, you need to move your mouse randomly to generate some data to encrypt the key pairs:
Once it has been generated, click “Next” then you will need to save the public key and private key to your computer. Save it in a safe place!
Click “Finish” When asked whether or not you want to upload the following key, say NO!
Copy the public key into your home directory using WinSCP:
Login to your Linux server with your username and password and cat the content of the public key:
First you need to format the public key properly, for this you need to delete the first four lines as well as delete the last line, and get JUST the key on a single line with “ssh-rsa” in front:
Note: Open the file with “nano <public key filename>” and you will be able to edit it properly.
Create the “authorized_keys” file inside .ssh folder and set the permission on it:
chmod 750 .ssh/authorized_keys
Important Note: If .ssh folder doesn’t exist then you can use these command to create it!
chmod 700 ~/.ssh
Now that the RSA key is properly formatted, you can add it to the “authorized_keys” file.
cat Identity.pub >> .ssh/authorized_keys
Remove the public key (In this case, it is Identity.pub):
Connecting via SecureCRT using your key pair:
If this is the same session you were already working with above, your identity file should already be filled in…if not, just click the browse button “…” and find your private key. Click “OK“. (You can also refer this link for more help):
It will not ask for the username and password
Hope this will help you!
Please Remember me in your prayers!