Set SSH public key authentication

Set SSH public key authentication to increase the security of your server. Login to it will require a private SSH key making your server more secure.
Prerequisite software:

Generate SSH key

  • Run Putty Key Generator
  • Click Generate
  • Move your mouse randomly over the blank area till the progress bar finish.
  • [Optional] Once key is generated, under the key comment textbox, add any word you like. Its recommended for you to remember what this key is about.
  • Protect your SSH key by adding a password or any word you’d like under Key passphrase and confirm passphrase. This will serve as your password to the SSH key so please remember it.
  • Click Save Public Key to the folder you like and name it as MySSHkey.ppk Keep this file.

Setup the Auto Login with SSH key using Putty

  • Run Peagent
  • On your systemtray, you can see Peagent. Right click and add Key and locate the folder where you save your SSH key (MySSHkey.ppk) and open it.
  • Enter your Key passphrase

Set your Putty to connect to your server

  • On Host name, enter your server’s ip address or the domain name.
  • On Saved Sessions, enter any name you want for this session
  • On the left side under Category list, click Data. Enter the Username (demo) on Auto-login username
  • Click Session under the Category and Click Save Button
  • Click Open. Enter the password. We’re not done yet.

Add the public key to the remote user

On the putty console and User(demo) is logged
1. Ensure that you have access to the user directory
sudo chown -R demo /home/demo

It may ask you to enter root password
2. Ensure you are in /home/demo directory
3. Create .ssh Directory and restrict permission
mkdir .ssh

chmod 700 .ssh
4. Create authorized_keys file and edit
nano .ssh/authorized_keys
5. Now switch to Putty Key Generator. Get your public key you created from Putty Key Generator. If you closed it don’t worry, follow this step:
  • Open Putty Key Generator
  • Click Load button
  • Locate your key MySSHkey.ppk from the folder you saved it
  • It will require you to enter your passphrase
  • Under Public key for pasting… you’ll see characters starting from ‘ssh-rsa’. You have to copy all of this. To do that, right click in the middle of it and click select all then right click again and click copy
6. Back to the Putty console again and paste the key. Right click in the middle of the console and the key will be pasted. Be careful not to type any thing as it will not work.
7. Save it by pressing ctrl+o and ctrl+x to exit
8. Restrict the permissions of the authorized_keys file
chmod 600 .ssh/authorized_keys
9. Open a new session on your Putty and open your server. It should login automatically.
* Please remember that auto-login will only work if Peagent is running and your key is added to it.

1 comment:

  1. My Linux Code: Set Ssh Public Key Authentication >>>>> Download Now

    >>>>> Download Full

    My Linux Code: Set Ssh Public Key Authentication >>>>> Download LINK

    >>>>> Download Now

    My Linux Code: Set Ssh Public Key Authentication >>>>> Download Full

    >>>>> Download LINK hN


Copyright © 2012 My Linux Code