Generate SSH2 (DSA) Key File on Windows PC/Laptop
- Open PuttyGen
- Change type of key to Generate to
SSH-2 DSA
. - Click
Generate
and 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 OpenSSH
and export your private key with filenameid_dsa.
- Click
Save private key
button 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 .ssh
chmod 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.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
- Open SSH Config file :
sudo nano /etc/ssh/sshd_config
- Change
Port 22
from standard toPort 2222
(or any other unused port for enhanced security) - Unhash and set
PasswordAuthentication no
(stops user/password entry) - Restart SSH to accept changes :
sudo service ssh restart
- Open Putty on Windows PC/Laptop.
- Under Category expand
ssh
and clickAuth
. - Under Authentication Parameters click
Browse
under "Private key file for authentication". - Browse and select the private key file (ppk) you saved earlier.
- Under Category expand
ssh
and 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
pi
or 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.