Generate SSH2 (DSA) Key File on Windows PC/Laptop
- Open PuttyGen
- Change type of key to Generate to
SSH-2 DSA. - Click
Generateand move mouse in blank area until random key generated. - Under Key comment enter
RaspberryPi Under Key Passphase and Confirm Passphrase enter a new secure passphrase (password)- Go to
Conversions->Export OpenSSHand export your private key with filenameid_dsa. - Click
Save private keybutton and save as a ppk file for later use. - Transfer newly generated SSH Private key to your Raspberry Pi (USB, Email, etc)
- Run the following code to create the SSH Directory on the Raspberry Pi :
cd ~mkdir .sshchmod 700 .ssh - Copy your SSH Private key you transferred to
~/.ssh/id_dsa - Run the following code to covert the SSH Private Key :
ssh-keygen -e -f ~/.ssh/id_dsa > ~/.ssh/id_dsa_com.pubssh-keygen -i -f ~/.ssh/id_dsa_com.pub > ~/.ssh/id_dsa.pubmv ~/.ssh/id_dsa.pub ~/.ssh/authorized_keyschmod 600 ~/.ssh/authorized_keys
- Open SSH Config file :
sudo nano /etc/ssh/sshd_config - Change
Port 22from standard toPort 2222(or any other unused port for enhanced security) - Unhash and set
PasswordAuthentication no(stops user/password entry) Save Config File (CTRL+x, Press Y and enter on filename)- Restart SSH to accept changes :
sudo service ssh restart
- Open Putty on Windows PC/Laptop.
- Under Category expand
sshand clickAuth. - Under Authentication Parameters click
Browseunder "Private key file for authentication". - Browse and select the private key file (ppk) you saved earlier.
- Under Category expand
sshand clickSession. - Under Host Name enter the IP Address of your Raspberry Pi.
- Under Port enter 2222 or the port number you configured ealrier.
- Under Saved Sessions enter
RaspberryPi - Click Save.
- Click Open.
- Login prompt should be displayed enter
pior you configured user name to access the Raspberry Pi. - If all successful you should then see Authenticating with public key and enter you secure passphrase.
- Enter secure Passphrase.
- You should now be connected securely to you Raspberry Pi.