Generate SSH2 (DSA) Key File on Windows PC/Laptop

  1. Open PuttyGen
  2. Change type of key to Generate to SSH-2 DSA.
  3. Click Generate and move mouse in blank area until random key generated.
  4. Under Key comment enter RaspberryPi
  5. Under Key Passphase and Confirm Passphrase enter a new secure passphrase (password)
  6. Go to Conversions->Export OpenSSH and export your private key with filename id_dsa.
  7. Click Save private key button and save as a ppk file for later use.
  8. Transfer newly generated SSH Private key to your Raspberry Pi (USB, Email, etc)  
Configure SSH on Raspberry Pi

  1. Run the following code to create the SSH Directory on the Raspberry Pi :
    cd ~
    mkdir .ssh
    chmod 700 .ssh
  2. Copy your SSH Private key you transferred to ~/.ssh/id_dsa
  3. Run the following code to covert the SSH Private Key : 
    ssh-keygen -e -f ~/.ssh/id_dsa > ~/.ssh/id_dsa_com.pub
    ssh-keygen -i -f ~/.ssh/id_dsa_com.pub > ~/.ssh/id_dsa.pub
    mv ~/.ssh/id_dsa.pub ~/.ssh/authorized_keys
    chmod 600 ~/.ssh/authorized_keys
Update & Restart SSH Config on Raspberry Pi
  1. Open SSH Config file :
    sudo nano /etc/ssh/sshd_config
  2. Change Port 22 from standard to Port 2222 (or any other unused port for enhanced security)
  3. Unhash and set PasswordAuthentication no (stops user/password entry)
  4. Save Config File (CTRL+x, Press Y and enter on filename)
  5. Restart SSH to accept changes :
    sudo service ssh restart 
Configure Putty to connect via SSH Private Key

  1. Open Putty on Windows PC/Laptop.
  2. Under Category expand ssh and click Auth.
  3. Under Authentication Parameters click Browse under "Private key file for authentication".
  4. Browse and select the private key file (ppk) you saved earlier.
  5. Under Category expand ssh and click Session.
  6. Under Host Name enter the IP Address of your Raspberry Pi.
  7. Under Port enter 2222 or the port number you configured ealrier.
  8. Under Saved Sessions enter  RaspberryPi
  9. Click Save.
  10. Click Open.
  11. Login prompt should be displayed enter pi or you configured user name to access the Raspberry Pi.
  12. If all successful you should then see Authenticating with public key and enter you secure passphrase.
  13. Enter secure Passphrase.
  14. You should now be connected securely to you Raspberry Pi.