What is the magic required to make SSH work.

I have booted into my Pi and enabled SSH under the settings. I know the IP address of my Pi which is static, I have tried on Windows with Putty and via terminal on a Mac. When I ping the Pi I get a reply.

I have read the first 10 answers on Google and all I can find is that SSH of late is disabled by default. I have enabled it so why doesn't it work.

I'm already very close to throw ing my Pi into the trash, hopefully its fate can be saved?

  • Did you verify that the ssh server is running? How exactly is an attempt to connect failing?
    – RalfFriedl
    Jul 1 '19 at 20:36
  • @RalfFriedl I have run "sudo systemctl enable ssh" - that created some symlinks. How can I verify the service running. When using putty I get connection time out, on a mac it just hangs
    – Alan A
    Jul 1 '19 at 20:44
  • You should add the information to the question. The enable command will just enable a service, not start it. start will start, status show whether it is running. The timeout indicates a firewall that blocks connections.
    – RalfFriedl
    Jul 1 '19 at 20:51
  • 2
    What operating system? What version? What steps have you taken? It is unclear what you have actually done.
    – joan
    Jul 1 '19 at 22:15
  • 1
    Have you tried re-enable it using raspi-config tool? Just last week I did it with a new fresh raspi3 and it worked straighforward. Jul 2 '19 at 14:01

You need to narrow down the problem step by step. First use a fresh flashed Raspbian Buster Light for troubleshooting. The light version reduces possible error sources. The unmodified version is guaranteed to work if you do not have broken hardware. Before starting the fresh installation place an empty file ssh into the boot directory you have to mount on your computer/laptop. For details look on at 3. Enable SSH on a headless Raspberry Pi (add file to SD card on another machine).

On the booted RasPi verify if the ssh server is running:

rpi@raspberrypi:~ $ systemctl status ssh.service

Try to connect local to the ssh server; confirm with yes. The asked password is the login password of user pi if you logged in with this user. You should get the login message. Exit ssh with exit.

pi@raspberrypi:~ $ ssh localhost
The authenticity of host 'localhost (::1)' can't be established.
ECDSA key fingerprint is SHA256:ROUpFKJ0Z64FobBlHfcIC1k78u01cxqG77d/CE5mH24.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'localhost' (ECDSA) to the list of known hosts.
pi@localhost's password:
Linux raspberrypi 4.19.50-v7+ #896 SMP Thu Jun 20 16:11:44 BST 2019 armv7l

The programs included with the Debian GNU/Linux system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.

Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.
Last login: Tue Jul  2 10:33:04 2019
pi@raspberrypi:~ $ exit
Connection to localhost closed.
pi@raspberrypi:~ $

You can also use the RasPis own ip address.

Now from a remote computer you should check with a network scanner if the ssh server on the RasPi is listening for connections on port 22. With a Linux operating system you can use nmap:

laptop ~$ nmap -p 22

Starting Nmap 7.40 ( https://nmap.org ) at 2019-07-02 11:50 CEST
Nmap scan report for
Host is up (0.0013s latency).
22/tcp open  ssh

Nmap done: 1 IP address (1 host up) scanned in 5.60 seconds
laptop ~$

As you can see my RasPi is listening with 22/tcp open ssh.

If all this tests are successful it is very likely that the Raspberry Pi is not the problem. Use the debug option -vvv of the ssh client on connection attempt, e.g. ssh -vvv pi@<ip-address>. This will give you a bunch of additional information for the connection.

If only nmap fails then you should look at your network configuration (wrong router configuration?, broken wire?).

  • I have tried an ssh connection form the pi itself and it was able to connect. I tried the -vvv switch on my PC and it appears to connect "debug1: Connection established." - however it then appears to be looking in .ssh folder for keys
    – Alan A
    Jul 2 '19 at 20:02
  • @AlanA Yes, ssh is first looking for key files and if it doesn't find one it falls back to password authentication. Maybe the ssh client on your PC isn't configured to use password authentication, but only private/public key authentication?
    – Ingo
    Jul 2 '19 at 20:10
  • I tried ssh in command prompt, putty and connection in an ftp client. For the ssh ftp session I set the user as pi - Connection timed out after 20 seconds of inactivity
    – Alan A
    Jul 2 '19 at 21:43
  • @AlanA ftp is not ssh. It cannot work because there is no ftp server running on the RasPi. What operating system do you use on the PC? You may consider to run a Linux system, maybe from a live CD.
    – Ingo
    Jul 2 '19 at 21:48
  • I meant sftp. PC is running Win10 but have also tried a Mac with similar results
    – Alan A
    Jul 2 '19 at 22:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.