stefan73
Posts: 3
Joined: Tue May 18, 2021 9:51 am

ssh connection refused

Tue May 18, 2021 10:12 am

Hi,

on 2021-03-04-raspios-buster-armhf-lite I try to login via ssh via USB but always get "connection refused.

What I did:
  • mounted the SD-card with the image and created the file "ssh" in boot
  • added a line "dtoverlay=dwc2" at the end of config.txt
  • added " modules-load=dwc2,g_ether" after "rootwait" in cmdline.txt
  • booted rpi connected by USB to my Ubuntu-Laptop
On Ubuntu I had to connect the rpi to the network. So I ...
  • sudo ifconfig to find out the new connection (it was "enx9a29d9305b78")
  • sudo ifconfig enx9a29d9305b78 192.168.178.11 netmask 255.255.255.0
ping worked, I could also access the webserver of the rpi by IP 192.168.178.11

ssh pi@192.168.178.11 always gave "connection refused.

ssh-keygen -R 192.168.178.11 didn't change anything.

What did I wrong?

Thank you!

User avatar
B.Goode
Posts: 12068
Joined: Mon Sep 01, 2014 4:03 pm
Location: UK

Re: ssh connection refused

Tue May 18, 2021 11:46 am

stefan73 wrote:
Tue May 18, 2021 10:12 am
Hi,

on 2021-03-04-raspios-buster-armhf-lite I try to login via ssh via USB but always get "connection refused.

What I did:
  • mounted the SD-card with the image and created the file "ssh" in boot
  • added a line "dtoverlay=dwc2" at the end of config.txt
  • added " modules-load=dwc2,g_ether" after "rootwait" in cmdline.txt
  • booted rpi connected by USB to my Ubuntu-Laptop
On Ubuntu I had to connect the rpi to the network. So I ...
  • sudo ifconfig to find out the new connection (it was "enx9a29d9305b78")
  • sudo ifconfig enx9a29d9305b78 192.168.178.11 netmask 255.255.255.0
ping worked, I could also access the webserver of the rpi by IP 192.168.178.11

ssh pi@192.168.178.11 always gave "connection refused.

ssh-keygen -R 192.168.178.11 didn't change anything.

What did I wrong?

Thank you!


What model of RPi board is involved here?


"ping worked, I could also access the webserver of the rpi by IP 192.168.178.11"

How was that webserver installed and configured? Do you have a locally connected keyboard and display to give you direct access to the RPi?

What do you believe to be the IP address of your Ubuntu laptop?

stefan73
Posts: 3
Joined: Tue May 18, 2021 9:51 am

Re: ssh connection refused

Tue May 18, 2021 12:51 pm

Ups, it's a Zero V.1.3.
The IP of my Laptop is 192.168.178.33
The web-server was preinstalled.
Unfortunately I don't have a keyboard for the pi, but I could connect the hdmi-out.

User avatar
thagrol
Posts: 4942
Joined: Fri Jan 13, 2012 4:41 pm
Location: Darkest Somerset, UK
Contact: Website

Re: ssh connection refused

Tue May 18, 2021 1:29 pm

stefan73 wrote:
Tue May 18, 2021 10:12 am
On Ubuntu I had to connect the rpi to the network. So I ...
  • sudo ifconfig to find out the new connection (it was "enx9a29d9305b78")
  • sudo ifconfig enx9a29d9305b78 192.168.178.11 netmask 255.255.255.0
ping worked, I could also access the webserver of the rpi by IP 192.168.178.11

ssh pi@192.168.178.11 always gave "connection refused.

ssh-keygen -R 192.168.178.11 didn't change anything.
If by "on ubuntu" you mean on your laptop, that's where your mistake is. That's the IP address of your laptop's end of the g_ether conection. You're pinging the laptop and trying to ssh into it.

Loading g_ether creates two usb interfaces, one on host and one on the Pi. Both need to be configured.

I'm not going to go over this (yet again) so a read of my guide here is probably a wise move on your part: viewtopic.php?f=91&t=306121&p=1851130#p1851130
I'm a volunteer. Take me for granted or abuse my support and I will walk away

All advice given is based on my experience. it worked for me, it may not work for you.
Need help? https://github.com/thagrol/Guides

User avatar
B.Goode
Posts: 12068
Joined: Mon Sep 01, 2014 4:03 pm
Location: UK

Re: ssh connection refused

Tue May 18, 2021 3:16 pm

stefan73 wrote:
Tue May 18, 2021 12:51 pm

The web-server was preinstalled.


I though this sounded odd, so I have just done a trial installation of RasPiOS Buster [32] Lite to check...

There is no webserver configured or started by default with this image of RasPiOS Lite.


I strongly suspect that you have connected to some other target system running a webserver, NOT your RPiZero.

stefan73
Posts: 3
Joined: Tue May 18, 2021 9:51 am

Re: ssh connection refused

Tue May 18, 2021 4:09 pm

Hi, sorry you are right! At the IP I mentioned it was configured as the rpi via USB my laptop answered. I just try to follow thagrols guide. So obviously I already configured the client-side of my USB-connection. Did not understand yet how to configure the host without having access to it. Need some time...

Return to “Troubleshooting”