Do it your self hobby code

Raspberry Pi – Auto login on terminal using SSH

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

  1. Run Putty Key Generator and click Generate
  2. Move your mouse randomly over the blank area till the progress bar finish.
  3. [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.
  4. 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.
  5. Click Save Public and Private key to your local drive.
  6. For the benefit of many, lets close the Key Generator.

You can still reopen the generated key by loading the private key.

  1. Open Putty Key Generator and click Load button
  2. Locate the private key file from the folder you saved it. It will require you to enter your passphrase
  3. 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

  1. On Host name, enter your Raspberry Pi hostname. Default is raspberrypi.local
  2. On Saved Sessions, enter any name you want for this session
  3. 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

cd

Create .ssh Directory and restrict permission

mkdir .ssh
chmod 700 .ssh

Create authorized_keys file and edit

nano .ssh/authorized_keys

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.

Using Pageant

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.

Leave a Comment

Your email address will not be published.