Raspberry Pi SSH connection refused - why?

Moderators: adafruit_support_bill, adafruit

Forum rules
Talk about Adafruit Raspberry Pi® accessories! Please do not ask for Linux support, this is for Adafruit products only! For Raspberry Pi help please visit: http://www.raspberrypi.org/phpBB3/
Locked
User avatar
50_RAIDs_of_Cray
 
Posts: 34
Joined: Sun Oct 28, 2012 10:29 am

Raspberry Pi SSH connection refused - why?

Post by 50_RAIDs_of_Cray »

I have set up my raspberry pi zero with the buster image, and added the ssh file to the boot directory. I have also edited config.txt and cmdline.txt according to this guide:
https://dev.webonomic.nl/connecting-to- ... sb-cable-i

However when I connect the pi to my desktop via USB, it shows up as an ethernet device with an IP address, but when I try to connect over SSH, I get "Connection Refused."

Why is the pi refusing my ssh connection? I can ping the device, and the ssh file gets deleted off the boot directory on startup (which it should based on what I see online).

User avatar
adafruit_support_mike
 
Posts: 67454
Joined: Thu Feb 11, 2010 2:51 pm

Re: Raspberry Pi SSH connection refused - why?

Post by adafruit_support_mike »

To check the obvious things first, are you sure sshd is running? It should be, but there’s a world of frustration between ‘should’ and ‘is’.

Also try using the IP address instead of ‘raspberrpi.local’. ssh wants to authenticate the names and addresses of both machines, and .local addresses require zetoconf/mdns. That might be enough to kill the connection.

User avatar
50_RAIDs_of_Cray
 
Posts: 34
Joined: Sun Oct 28, 2012 10:29 am

Re: Raspberry Pi SSH connection refused - why?

Post by 50_RAIDs_of_Cray »

I have used the IP address, not the alias of raspberrypi.local.

As for SSHD, do you mean on my desktop? I am using MobaXTerm (similar to PuTTY). It should handle sshd. Both MobaXTerm and Powershell get a "Connection Refused" so it's like ssh on the pi wants something more but I don't know what to give it.

User avatar
adafruit_support_mike
 
Posts: 67454
Joined: Thu Feb 11, 2010 2:51 pm

Re: Raspberry Pi SSH connection refused - why?

Post by adafruit_support_mike »

No, I meant “is sshd running on the RasPi?” It should be, but “Connection refused” is the standard message when it isn’t running.

My thought was that some error might be forcing sshd on the RasPi to quit, so there’s no daemon when you try to log in.

User avatar
50_RAIDs_of_Cray
 
Posts: 34
Joined: Sun Oct 28, 2012 10:29 am

Re: Raspberry Pi SSH connection refused - why?

Post by 50_RAIDs_of_Cray »

What can I do about that? With a headless device like this (no monitor or keyboard) and no serial connection I can't see any error output on boot.

User avatar
adafruit_support_mike
 
Posts: 67454
Joined: Thu Feb 11, 2010 2:51 pm

Re: Raspberry Pi SSH connection refused - why?

Post by adafruit_support_mike »

That’s the point where I’d reach for the PiUART:

https://www.adafruit.com/product/3589

That’s my go-to method of doing headless setup, and most of the RasPis I use are headless.

You can also use a Serial cable if you have one, or in a pinch you can use a microcontroller with USB as a Serial bridge: connect the hardware Serial port to the RasPi’s GPIO header and write code that passes data between the hardware Setial pins and the USB Serial connection to the computer. Anything that comes from the RasPi on the hardware Serial RX pin gets copied to the USB Serial TX pin, and anything that comes from the computer on the USB Serial RX gets passed to the hardware Serial TX pin. Then you can use the Arduino IDE’s Serial Monitor as a terminal.

Another option is to move the SD card to another RasPi that does have a monitor and keyboard. You can do some basic configuration there.. at least enough for you to get a login through the USB cable.. then move the SD back to the Zero.

User avatar
50_RAIDs_of_Cray
 
Posts: 34
Joined: Sun Oct 28, 2012 10:29 am

Re: Raspberry Pi SSH connection refused - why?

Post by 50_RAIDs_of_Cray »

Thanks I'll try that.

User avatar
50_RAIDs_of_Cray
 
Posts: 34
Joined: Sun Oct 28, 2012 10:29 am

Re: Raspberry Pi SSH connection refused - why?

Post by 50_RAIDs_of_Cray »

Ok, here I am a week later, I received the PiUART and used to access the Pi's command line. I used the config utility to turn on SSH and Serial. Upon reboot neither of those works.

I am using the Pi over USB, no longer with the PiUART attached because I shouldn't need it now. I cannot SSH into the pi due to the same error as before (connection refused) nor is there a COM port that comes up. The Pi does show up with an IP address when I plug in the USB connection so I know it's presenting on that channel.

What the heck is going on here? Why can I not SSH into this? Is there something I have to do after using the config utility to activate SSH?

User avatar
50_RAIDs_of_Cray
 
Posts: 34
Joined: Sun Oct 28, 2012 10:29 am

Re: Raspberry Pi SSH connection refused - why?

Post by 50_RAIDs_of_Cray »

(posting again since I can't edit) The Pi shows up as "USB Ethernet/RNDIS Gadget #3" in my device manager (using Windows 10). That's the Ethernet-over-USB interface I'm using with an assigned IP address to try to SSH to it.

User avatar
adafruit_support_mike
 
Posts: 67454
Joined: Thu Feb 11, 2010 2:51 pm

Re: Raspberry Pi SSH connection refused - why?

Post by adafruit_support_mike »

Checking the details, if you use:

Code: Select all

ps ax | grep ssh
Do you see sshd running or not?

User avatar
50_RAIDs_of_Cray
 
Posts: 34
Joined: Sun Oct 28, 2012 10:29 am

Re: Raspberry Pi SSH connection refused - why?

Post by 50_RAIDs_of_Cray »

This is what I see after a reboot:

Code: Select all

pi@raspberrypi:~$ ps ax | grep ssh
  367 ?        Ss     0:00 /usr/sbin/sshd -D
  504 ?        Ss     0:00 /usr/bin/ssh-agent x-session-manager
  548 ?        Ss     0:00 /usr/bin/ssh-agent -s
  552 ?        S      0:00 sh /etc/xdg/lxsession/LXDE-pi/sshpwd.sh
 1697 ttyS0    S+     0:00 grep --color=auto ssh

User avatar
adafruit_support_mike
 
Posts: 67454
Joined: Thu Feb 11, 2010 2:51 pm

Re: Raspberry Pi SSH connection refused - why?

Post by adafruit_support_mike »

Okay, the daemon is running.

The next step is to see what it has to say while you try to log in. Let’s start with general information. In your Serial connection, enter:

Code: Select all

tail -f /var/log/syslog
If the sshd has complaints, it may dump them to syslog and you’ll see them pop up as they arrive.

To stop watching the file, hit control-c.

If syslog doesn’t say anything, trym

Code: Select all

sudo tail -f /var/log/authlog
Any problems related to a login should go there.

User avatar
50_RAIDs_of_Cray
 
Posts: 34
Joined: Sun Oct 28, 2012 10:29 am

Re: Raspberry Pi SSH connection refused - why?

Post by 50_RAIDs_of_Cray »

Solved, I had to turn off my VPN

The syslog shows:

Code: Select all

Feb 14 03:24:16 raspberrypi dhcpcd[289]: usb0: soliciting a DHCP lease
Feb 14 03:24:17 raspberrypi dhcpcd[289]: usb0: soliciting an IPv6 router
Feb 14 03:24:21 raspberrypi dhcpcd[289]: usb0: probing for an IPv4LL address
Feb 14 03:24:27 raspberrypi dhcpcd[289]: usb0: using IPv4LL address 169.254.45.228
Feb 14 03:24:27 raspberrypi dhcpcd[289]: usb0: adding route to 169.254.0.0/16
Feb 14 03:24:27 raspberrypi dhcpcd[289]: usb0: adding default route
Feb 14 03:24:27 raspberrypi avahi-daemon[298]: Joining mDNS multicast group on interface usb0.IPv4 with address 169.254.45.228.
Feb 14 03:24:27 raspberrypi avahi-daemon[298]: New relevant interface usb0.IPv4 for mDNS.
Feb 14 03:24:27 raspberrypi avahi-daemon[298]: Registering new address record for 169.254.45.228 on usb0.IPv4.
and that IP address is shown when I use $ifconfig. However on my PC, when I try to ping that address I get "General Failure" back which I've never seen before. So I can't even ping it.

I looked up what causes this and one possibility was my VPN. So I disabled my VPN and now I can finally ping the device over Ethernet-over-USB, and I can ssh in! I was using ProtonVPN, perhaps it messed up my system's ability to interact over a local IPv4 network.

Thank you for all your help.

User avatar
adafruit_support_mike
 
Posts: 67454
Joined: Thu Feb 11, 2010 2:51 pm

Re: Raspberry Pi SSH connection refused - why?

Post by adafruit_support_mike »

Hmm.. new information for me. Glad to hear you found the problem, and thanks for posting the follow-up!

Locked
Forum rules
Talk about Adafruit Raspberry Pi® accessories! Please do not ask for Linux support, this is for Adafruit products only! For Raspberry Pi help please visit: http://www.raspberrypi.org/phpBB3/

Return to “Adafruit Raspberry Pi® accessories”