SSH configuration in Raspberry Pi

Enabling default SSH access

In order to enable SSH access after downloading Raspbian Lite without desktop environment and writhing it to SD card you must add empty file called ’ssh’ (no extension) on boot drive while your SD card is still connected to your PC. Next place the SD card in your Raspberry Pi and boot.

Login to Raspberry Pi using SSH connection

In command line type with your Raspberry Pi IP address:


and provide default password raspberry

Change default password

Change password using this command:


Configure password less SSH access

First make sure that you have keys generated for your client (PC). If you using Cmder on Windows 10 check following directory for files id_rsa and


Or generate new pair

ssh-keygen -f ./rpi-access

Add identity to ssh agent

ssh-add ./rpi-access

Next copy the public key

ssh-copy-id -i ./rpi-access

Disable logging with password

For security reasons it is better to disable asscess with password and use only key dependent authentication, so edit the ssh configuration file:

sudo nano /etc/ssh/sshd_config

Find line

#PasswordAuthentication yes

remove comment (# character) and change value to no

PasswordAuthentication no

Now restart the service or reboot the Raspberry

sudo /etc/init.d/ssh restart
sudo reboot

Changing SSH port

This is an optional step, you can change the default port from 22 to something else by editing SSH config file:

sudo nano /etc/ssh/sshd_config

change the port 22 to something else and restart SSH service as in previos

Port 50022

Next restart the ssh service

sudo service ssh restart

Start ssh agent on local machine

eval $(ssh-agent)