What is the SSH password for Raspberry Pi?

Today we will focus on a topic that interests everyone, i.e. everything that is related to the SSH connection to your Raspberry Pi

First of all, what is the default SSH password of the Raspberry Pi?
To log in SSH to the Raspberry Pi the first time you must use the following credentials:
– login: pi
– password: raspberry

But we will also see in detail many other points on SSH connections to Raspberry Pi, including:
– What is SSH?
– How to activate SSH on a Raspberry Pi?
– How to make the SSH service start automatically at each reboot?
– Which IP address and which port to connect?
– How not to have to type a password to log in SSH?

What is SSH?

SSH stands for Secure SHell
It’s a cryptographic network protocol that is most used to connect to another computer on a network securely

In practice, SSH will allow you to access the shell (terminal) of your Raspberry Pi from another pc
This solution can be convenient if you want to install things from your main pc or even essential if you don’t use a screen with your Raspberry Pi

In the next paragraphs, we will see how to put this in place step by step, starting with the basics, then adding a little bit of comfort

How to connect to Raspberry Pi with SSH?

From Windows

If you use Microsoft Windows on your main pc, be aware that there is no tool for an ssh connection that is installed by default
That’s why you will have to download and install one, like Putty for exemple

Putty is one of the most used software to use SSH on Windows, and if you start it will be perfect

Download the file matching your computer specifications
Depending on the version chosen, install it or not, then launch it

Putty look like this :

puTTy configuration

To log in, type the IP address in the “Host Name” field and click on “Open”
If you need help to find the current IP address of Raspberry Pi, feel free to read my article on the subject

As a reminder, the default SSH login and password are:
– Login: pi
– Password: raspberry

If it does not work for now do not worry, then I’ll explain what to do

From Linux or Mac

If you use a Unix-based system, i.e., any Linux distribution or even Mac OS, you will have to use the “ssh” command to connect from a terminal

It will sometimes be necessary to install it, for example on a distribution based on Debian:

sudo apt-get update
sudo apt-get install ssh

The command to connect to your Raspberry Pi will be something like this:

ssh pi@IP

Replace IP by the IP address of your Raspberry Pi
If you need help to find the current IP address of Raspberry Pi, feel free to read my article on the subject

As a reminder, the default SSH login and password are:
– Login: pi
– Password: raspberry

If it does not work for now do not worry, then I’ll explain what to do

How to enable SSH on a Raspberry Pi?

From the desktop

For security reasons, the SSH service is not enabled by default on Raspberry Pi
You must activate it yourself by going to the menu Start> Preferences> Raspberry Pi Configuration
Go to the “Interfaces” tab and enable SSH

From a terminal

The same thing from a terminal, you will have to start the SSH service manually
To do this, type the following command:

sudo service ssh start

You can also check the service status by typing:

sudo service ssh status

How to auto start SSH on boot?

You will quickly realize that the SSH service, even when enabled, does not start automatically at startup
So you have to find a way to force it to start

I guess there are several ways to do it, for my part I chose to add a cron for root that launch SSH at each startup:

  1. Edit the root crontab like this :
    sudo crontab -e
  2. Add this line at the end of the file :
    @reboot /usr/sbin/service ssh start

If this is not very clear for you, do not hesitate to read the tutorial on how to schedule tasks on Raspberry Pi
It explains in detail these notions of cron and crontab, and I even believe that the start of SSH on boot was one of the examples given

Which IP address and port to connect?

By default, the SSH service start on port 22
You must, therefore, connect to the IP of the Raspberry Pi indicating the port 22

For example from Linux:

ssh pi@192.168.1.200

Or if you changed the SSH port, specify the port with the -p option:

ssh pi@192.168.1.200 -p2222

Replace 2222 with the port chosen

As mentioned above, if you do not know the current IP address of the Raspberry Pi, do not hesitate to take a look at my post on the subject.
I will explain to you how to find it
This post will also tell how to set it static, so you do not have to search for it every time you want to log in again

How to connect SSH without password?

You now know how to activate the SSH service on your Raspberry Pi and how to connect to it
That’s great, but if you have to do it as often as I do, typing the password every time will quickly become boring

There is a way to create an SSH key to identify you with it and no longer with the user’s password
I will explain how to set this up according to your operating system

Of course, the password connection will still be possible if you lose the key or use another computer

From Windows

First thing, on Windows you will need the full suite of Putty, with PuttyGen and PuttyAgent
So if you downloaded only the SSH client in the portable version, you have to install all the rest

You will also need a tool to transfer a file to your Raspberry Pi
WinSCP should be a good choice

Then follow these steps

  1. Create your SSH Keys with PuttyGen :
    1. Start PuttyGen
    2. Select RSA as the type of key
    3. Enter 4096 as the number of bits
    4. Click Generate
    5. Let all other options by default, no passphrase
    6. Save the keys where you want
  2. Transfer the public key to the Raspberry Pi with WinSCP
    1. Add a new site with our RaspBerry Pi IP and credentials
    2. Connect to this site
    3. On the left side, go to the folder where you saved your keys
    4. On the right side, go to the /home/pi folder
    5. Transfer the public key to the Raspberry (drag & drop)
  3. Allow this key on the Raspberry Pi
    1. Connect to the Raspberry Pi with Putty
    2. Add the public keys just transferred to the allowed keys :
      cat /home/pi/you_key.pub >> ~/.ssh/authorized_keys
    3. Close putty
  4. Try to connect again with Putty

This trial should not require you to type a password and log in directly

If you still need a login, enter pi@IP in the “Hostname” field by replacing IP with the IP address of the Raspberry Pi

From Linux or Mac

  1. If you don’t already have one, create your SSH keys with this command :
    ssh-keygen -t rsa

    Just type enter to each question, default path, and no password

  2. Copy the public key file to your raspberry pi :
    cp ~/.ssh/id_rsa.pub pi@IP:/home/pi/your_key.pub

    Replace IP with your Raspberry Pi IP address, name the key as you want

  3. Add this key to the allowed keys using this command on the Raspberry Pi :
    cat /home/pi/you_key.pub >> ~/.ssh/authorized_keys
  4. Try to connect again :
    ssh pi@IP

    This trial should not require you to type a password and log in directly

Here you are at maximum comfort to use SSH from this pc 🙂

Conclusion

And that’s it, you now know:
– What is SSH
– How to activate SSH on a Raspberry Pi
– How to make the SSH service start automatically at each reboot
– Which IP address and which port to connect to
– How not to have to type a password to log in ssh

If you have any other questions or are stuck somewhere, do not hesitate to ask for help in the comments

 

Leave a Comment