Raspberry Pi Auto login using SSH. Getting tired of entering the username and password when using Putty. Here is a quick tutorial on how to configure your Raspberry Pi and Putty to access the terminal without the use of username and password. Its a secure login process using SSH.
Please watch this tutorial video
What you need:
Generate SSH key
- Run Putty Key Generator and 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 and Private key to your local drive.
- For the benefit of many, lets close the Key Generator.
You can still reopen the generated key by loading the private key.
- Open Putty Key Generator and click Load button
- Locate the private key file 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’. This is the key that we will copy later.
Applying SSH key to your Rasberry Pi
Set your Putty to connect to Raspberry Pi
- On Host name, enter your Raspberry Pi hostname. Default is raspberrypi.local
- On Saved Sessions, enter any name you want for this session
- Click Save and Open and login again. We’re not done yet.
Add the public key to the pi user
On the putty console, ensure that you are in the user home directory
Create .ssh Directory and restrict permission
mkdir .ssh chmod 700 .ssh
Create authorized_keys file and edit
Back to Putty Key Generator. Under Public key for pasting… you’ll see characters starting from ‘ssh-rsa’. Copy this key. Right click in the middle of it and click select all then right click again and click copy
On Putty console, 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.
Save it by pressing ctrl+o and ctrl+x to exit
Restrict the permissions of the authorized_keys file
chmod 600 .ssh/authorized_keys
Close Putty console.
Run Peagent. On your systemtray, you can see Peagent.Click it, add Key and locate the folder where you save your Private SSH key. Enter your Key passphrase
Last configuration for Putty
1. On Putty, left side under Category list, click Data. Enter the Username (pi) on Auto-login username
2. Click Session under the Category and Click Save Button
3. Click Open. It should login automatically.
Please remember that auto-login will only work if Peagent is running and private key is added to it.