Raspberry Pis will not connect via SSH

Can you guide me on that? Sorry

This is bound to fail because it’s using ssh to copy the id. If ssh doesn’t work, obviously it can’t copy the the new key. You have to transfer the key from either another working computer or unmount the sd-card and edit the ~/.ssh/authorized_keys file manually.

However, the error message should be different. There are so many things that can go wrong, it’s hard to guess.

Can you verify your whole setup is correct, meaning that you are, in fact, connected to the same network. Is any device connected to the guest wifi? (The 188 in the IP address might suggest this.)
Did you disallow network communication in your router?

How are you connecting to the pi currently? If you have ufw running on the pi, you have to allow port 22 there, not on your local machine.

All commands need to run on your Pi, not on the client. You might need connect your Pi to a screen and keyboard.

systemctl status sshd

and check with ss if something is listing on port 22

 ss -nlt | grep 22
     Loaded: loaded (/usr/lib/systemd/system/sshd.service; enabled; vendor pres>
     Active: active (running) since Mon 2022-01-17 21:52:56 AEDT; 33min ago
   Main PID: 699 (sshd)
      Tasks: 1 (limit: 9362)
     Memory: 3.1M
        CPU: 19ms
     CGroup: /system.slice/sshd.service
             └─699 "sshd: /usr/bin/sshd -D [listener] 0 of 10-100 startups"

Jan 17 21:52:56 pc systemd[1]: Started OpenSSH Daemon.
Jan 17 21:52:57 pc sshd[699]: Server listening on port 2222.
Jan 17 21:52:57 pc sshd[699]: Server listening on :: port 2222.
LISTEN 0      128*          
LISTEN 0      128             [::]:2222         [::]:* 

Not sure why its listening on port 2222, I may have changed something

Then you need to connect to port 2222 and not 22. You can use the -p 2222 option.

If you use a firewall on your Pi, make sure you open port 2222.

It still comes up as connection refused. The underlying issue may be the outdated keygens

But a refused error is not an error from sshd, it is from the network stack. If it is a problem with keys you would see it in the server journal. and of course in the debugging output of your ssh command.

Check it on your Pi,

journalctl -b -u sshd --no-host --no-pager 

If you don’t see any connection attempt, the ssh sever never processed it.

Also is there any reason why you use sudo?

If you want to log in as root do

ssh -p 2222 root@ 

I’ve installed a minimal image on my pi, due to creating a pi cluster

You cannot login as root without keyfile unless you have specifically enabled this in your host’s


#PermitRootLogin prohibit-password

For any change to have effect you must reload the ssh daemon.


Sorry, what does this do again?

The setting is default - and it only allows root login using keybased login.

man sshd_config
             Specifies whether root can log in using ssh(1).  The argument must be yes, prohibit-password,
             forced-commands-only, or no.  The default is prohibit-password.

             If this option is set to prohibit-password (or its deprecated alias, without-password), password and keyboard-in‐
             teractive authentication are disabled for root.

             If this option is set to forced-commands-only, root login with public key authentication will be allowed, but
             only if the command option has been specified (which may be useful for taking remote backups even if root login
             is normally not allowed).  All other authentication methods are disabled for root.

             If this option is set to no, root is not allowed to log in.

By default, you can’t log in as root with a password. Only a normal user can login with a password. If you want to login as root with a password you need to configure sshd, to allow this.

However, it considered less secure. Don’t do it. Either login as a normal user and switch to root (su -) or set up keys. To do this login as a normal user with a passwort and set up keys for this user and the root user.

A little bit to read


I’m still not sure what this does :face_with_diagonal_mouth:

At the moment it really doesn’t matter since it is will probably not fix it. Because even if a password login for root is disabled, you should be able to try to login. For example,

$ ssh root@test.vir
root@test.vir's password:
Permission denied, please try again.
root@test.vir's password:
Permission denied, please try again.
root@test.vir's password:
Connection closed by port 22

At first you still need to find out, if you can connect to your Pi over ssh by port 2222. If possible do not use root, use a normal user. Do not use sudo. simple ssh -vvv -p 2222 username@IP .

Also verfiy if the IP you use is correct.

I’m looking through the contents on the SD card on my Raspberry Pi in Windows (as it is very weird on Manjaro) and they aren’t what they should be. I cannot find some of the files I had created on it and some of the edits I made are missing too. I am unsure why it is like this, perhaps looking through the contents on linux does something to it or it may as well be my SD card reader because it is quite cheap.

I was willing to ask for help as a means to learn if a reocurring issue ever came across again. But I might as well just make a clean install on the SD cards.

You won’t be able to read the Ext4 partition from Windows, you will only be able to see the boot partition.

Checking it on linux and it is different. But, I’ll just do a fresh install on the SD cards, it will save the time and hassle.

Thank you everyone for trying to help, I really do appreciate it :slight_smile:

Be very careful what you do with Ssh… You are basically punching a hole though your firewall. If you are going to exposed it to the outside world.