Is an SSH connection a permanent connection

Raspberry Pi: Establish SSH connection

An SSH connection to the Raspberry Pi can be established for remote maintenance via the command line. For this, the Raspberry Pi must be connected to the network via Ethernet or WiFi.

An SSH client and the IPv4 address of the Raspberry Pi are required on the local system. In computer systems with Mac OS and Linux, the SSH client is already integrated on the command line. Here you just have to call up a terminal program.
Under Windows you also have to install an SSH client (e.g. PuTTY).

Note: Since the Raspbian Jessie image from 2016-11-25, SSH is disabled by default for security reasons.

Solution with Mac OS or Linux: Establish SSH connection

First you call up a terminal program. Then enter the following command in the command line. Enter the IP address or the host name of the Raspberry Pi as "HOST".

ssh pi @ {HOST}

If a connection to the IPv4 address is possible and the standard user "pi" exists, the password must be entered "blindly". This means that the keyboard input is not displayed. It looks like nothing is entered.


Then you have to confirm the authenticity of the answering remote station (once). The SSH connection is then successfully established.

Note: If the user name is not entered in the addressing (pi @ ...), the SSH client tries to log in with the local user. This usually does not work because you are usually not logged in with the same user here.

Solution under Windows: Establish SSH connection

We recommend installing PuTTY, which is also available as an executable program without installation. After starting PuTTY, enter the IPv4 address of the Raspberry Pi and user name "pi" and the password "raspberry". "SSH" and port 22 should be selected. Then you start the connection with "Connect". After accepting the certificate (once), the SSH connection is then successfully established.

Troubleshooting: Find out the IP address

After the first commissioning of a Raspberry Pi, establishing a connection via SSH is difficult because the IPv4 address of the Raspberry Pi was assigned dynamically via DHCP and you do not yet know it. It is easier if you set up the connection with the host name of the Raspberry Pi.

Troubleshooting: Establishing a connection after the system has started

Since there is no screen output, of course you do not know when the Raspberry Pi is finished with the system start. A look at the status LEDs on the circuit board will help. During the system start, the red LED lights continuously and the green one flashes or flickers. After the system has started, the red LED lights up continuously and the green LED usually stops flashing. Then you can be pretty sure that the Raspberry Pi has started successfully and that you can connect via SSH.

Troubleshooting: SSH connection with macOS

If you connect to a Raspberry Pi via SSH, the following error message can appear in a macOS or Linux terminal:

@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @@@@@@@@@ @ WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED! @ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @@@@@@@@@@ ...

The error message states that the host name or IP address of the "remote host" does not match the stored public key. This can mean connecting to the wrong host. This can happen if the IP address changes.
The problem with this is that the connection doesn't work, which is the right thing to do. An attacker could have crept into the connection.

Usually nobody pretends to be someone else, something has changed. For example the IP address or the host name or the key. As a user, you therefore have to intervene manually in order to delete the stored authentication data.

Remove the key on macOS:

ssh-keygen -R {IP ADDRESS / HOSTNAME}

Or delete the whole file:

rm .ssh / known_hosts

Other related topics:

Experience electronics with the Raspberry Pi

All-in-one electronics starter kit for every Raspberry Pi

With breakout board, ribbon cable, breadboard and many electronic components. The whole package is rounded off with an English-language tutorial with programming examples in C, Python and Java for download.

I want that!