2

So this is driving me crazy.

Basically my problem is that I can ssh to the pi if the ethernet cable is connected but not if disconnected. It sounds like a typical network problem so far, but it is not: I can ping it, I can apt update from wifi; I even installed later lighttpd and I can access a simple html page I created. It's just ssh the only service that doesn't want to work over wifi without the ethernet cable disconnected.

I found this other question but I think it is not related because sshd is running. I can get up to the initial prompt (login, motd and prompt shown) but when I type into the terminal nothing happens, or it happens but after several tens of seconds. I can also see the process getting started when I login.

Just in case it was a client issue I tried connecting from different computers (I use linux so I just do ssh pi@192.168.0.105) but all show the same behavior.

The pi is very close to the router and the signal quality and strength are very good, so it is not a signal problem.

And even more crazy: When the eth cable is connected, both, using the wifi and the ethernet IP's ssh works perfectly. And the ping delay gets shortened if the cable is connected, even if I am pinging the wifi ip!

Just in case I tried also disabling the power management of the wifi with iwconfig wlan0 power off but I thing that it is already disabled by default always.

This is a system where I just installed raspbian lite, enabled shh in raspi-config, dist-upgraded and not much else. Also, I'm using a Raspberry Pi 3 Model B v1.2. My router does not block any port in the local network.

Anyone has seen this happening before? Any ideas on how to solve it? I have been using linux for years and never had anything like this before.


Edit ip a and ip r:

With ethernet connected:

$ ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host 
       valid_lft forever preferred_lft forever
2: enxb827eb159633: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
    link/ether b8:27:eb:15:96:33 brd ff:ff:ff:ff:ff:ff
    inet 192.168.0.106/24 brd 192.168.0.255 scope global noprefixroute enxb827eb159633
       valid_lft forever preferred_lft forever
    inet6 2408:210:5a5:8d00:3387:d43a:d21a:5dbf/64 scope global dynamic mngtmpaddr noprefixroute 
       valid_lft 2591866sec preferred_lft 604666sec
    inet6 fe80::a845:cbec:5d50:a017/64 scope link 
       valid_lft forever preferred_lft forever
3: wlan0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
    link/ether b8:27:eb:40:c3:66 brd ff:ff:ff:ff:ff:ff
    inet 192.168.0.105/24 brd 192.168.0.255 scope global noprefixroute wlan0
       valid_lft forever preferred_lft forever
    inet6 2408:210:5a5:8d00:a898:f644:ea88:5dd0/64 scope global dynamic mngtmpaddr noprefixroute 
       valid_lft 2591866sec preferred_lft 604666sec
    inet6 fe80::9e85:4221:de76:1b54/64 scope link 
       valid_lft forever preferred_lft forever
$ ip r
default via 192.168.0.1 dev enxb827eb159633 proto dhcp src 192.168.0.106 metric 202 
default via 192.168.0.1 dev wlan0 proto dhcp src 192.168.0.105 metric 303 
192.168.0.0/24 dev enxb827eb159633 proto dhcp scope link src 192.168.0.106 metric 202 
192.168.0.0/24 dev wlan0 proto dhcp scope link src 192.168.0.105 metric 303

Without ethernet connected:

$ ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host 
       valid_lft forever preferred_lft forever
2: enxb827eb159633: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc pfifo_fast state DOWN group default qlen 1000
    link/ether b8:27:eb:15:96:33 brd ff:ff:ff:ff:ff:ff
3: wlan0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
    link/ether b8:27:eb:40:c3:66 brd ff:ff:ff:ff:ff:ff
    inet 192.168.0.105/24 brd 192.168.0.255 scope global noprefixroute wlan0
       valid_lft forever preferred_lft forever
    inet6 2408:210:5a5:8d00:a898:f644:ea88:5dd0/64 scope global dynamic mngtmpaddr noprefixroute 
       valid_lft 2591691sec preferred_lft 604491sec
    inet6 fe80::9e85:4221:de76:1b54/64 scope link 
       valid_lft forever preferred_lft forever
$ ip r
default via 192.168.0.1 dev wlan0 proto dhcp src 192.168.0.105 metric 303 
192.168.0.0/24 dev wlan0 proto dhcp scope link src 192.168.0.105 metric 303 

Logs of ssh in verbose while connecting without the cable plugged in:

desktop:~$ ssh -v pi@192.168.0.105
OpenSSH_7.6p1 Ubuntu-4ubuntu0.3, OpenSSL 1.0.2n  7 Dec 2017
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: Applying options for *
debug1: Connecting to 192.168.0.105 [192.168.0.105] port 22.
debug1: Connection established.
debug1: key_load_public: No such file or directory
debug1: identity file /home/nake/.ssh/id_rsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/nake/.ssh/id_rsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/nake/.ssh/id_dsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/nake/.ssh/id_dsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/nake/.ssh/id_ecdsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/nake/.ssh/id_ecdsa-cert type -1
debug1: identity file /home/nake/.ssh/id_ed25519 type 3
debug1: key_load_public: No such file or directory
debug1: identity file /home/nake/.ssh/id_ed25519-cert type -1
debug1: Local version string SSH-2.0-OpenSSH_7.6p1 Ubuntu-4ubuntu0.3
debug1: Remote protocol version 2.0, remote software version OpenSSH_7.9p1 Raspbian-10+deb10u1
debug1: match: OpenSSH_7.9p1 Raspbian-10+deb10u1 pat OpenSSH* compat 0x04000000
debug1: Authenticating to 192.168.0.105:22 as 'pi'
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: algorithm: curve25519-sha256
debug1: kex: host key algorithm: ecdsa-sha2-nistp256
debug1: kex: server->client cipher: chacha20-poly1305@openssh.com MAC: <implicit> compression: none
debug1: kex: client->server cipher: chacha20-poly1305@openssh.com MAC: <implicit> compression: none
debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
debug1: Server host key: ecdsa-sha2-nistp256 SHA256:Xjwb/7yoQctf7IE3h00o6nVBT+/g4TtQm0ZtCeYNAGc
debug1: Host '192.168.0.105' is known and matches the ECDSA host key.
debug1: Found key in /home/nake/.ssh/known_hosts:9
debug1: rekey after 134217728 blocks
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: rekey after 134217728 blocks
debug1: SSH2_MSG_EXT_INFO received
debug1: kex_input_ext_info: server-sig-algs=<ssh-ed25519,ssh-rsa,rsa-sha2-256,rsa-sha2-512,ssh-dss,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521>
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey,password
debug1: Next authentication method: publickey
debug1: Trying private key: /home/nake/.ssh/id_rsa
debug1: Trying private key: /home/nake/.ssh/id_dsa
debug1: Trying private key: /home/nake/.ssh/id_ecdsa
debug1: Offering public key: ED25519 SHA256:6AJUW1IGCWvl/nSpWqgS9gQCJBIdmPULsgsFXNfxRuA /home/nake/.ssh/id_ed25519
debug1: Authentications that can continue: publickey,password
debug1: Next authentication method: password
pi@192.168.0.105's password: 
debug1: Authentication succeeded (password).
Authenticated to 192.168.0.105 ([192.168.0.105]:22).
debug1: channel 0: new [client-session]
debug1: Requesting no-more-sessions@openssh.com
debug1: Entering interactive session.
debug1: pledge: network
debug1: client_input_global_request: rtype hostkeys-00@openssh.com want_reply 0
debug1: Sending environment.
debug1: Sending env LC_MEASUREMENT = ja_JP.UTF-8
debug1: Sending env LC_PAPER = ja_JP.UTF-8
debug1: Sending env LC_MONETARY = ja_JP.UTF-8
debug1: Sending env LANG = es_ES.UTF-8
debug1: Sending env LC_NAME = ja_JP.UTF-8
debug1: Sending env LC_ADDRESS = ja_JP.UTF-8
debug1: Sending env LC_NUMERIC = ja_JP.UTF-8
debug1: Sending env LC_TELEPHONE = ja_JP.UTF-8
debug1: Sending env LC_IDENTIFICATION = ja_JP.UTF-8
debug1: Sending env LC_TIME = ja_JP.UTF-8
Linux pi 4.19.75-v7+ #1270 SMP Tue Sep 24 18:45:11 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: Sat Oct 19 15:01:52 2019 from 192.168.0.108
pi@pi:~ $

Several notes: It gets stuck for a few seconds after the last debug1: Sending env LC_TIME = ja_JP.UTF-8, before showing the motd. After the shell is open, I can type and sometimes the key is shown, but most of the times it is just stuck there forever. Not even ctrl-d works most of the time, or it does after several tens of seconds.

When the connection succeeds I can see the status of sshd and the connection being open (still, without ethernet being plugged in):

$ systemctl status sshd
● ssh.service - OpenBSD Secure Shell server
   Loaded: loaded (/lib/systemd/system/ssh.service; enabled; vendor preset: enabled)
   Active: active (running) since Sat 2019-10-19 11:44:53 JST; 3h 26min ago
     Docs: man:sshd(8)
           man:sshd_config(5)
 Main PID: 493 (sshd)
    Tasks: 1 (limit: 2077)
   Memory: 6.6M
   CGroup: /system.slice/ssh.service
           └─493 /usr/sbin/sshd -D

Oct 19 13:18:44 pi sshd[2892]: pam_unix(sshd:session): session opened for user pi by (uid=0)
Oct 19 14:13:06 pi sshd[3082]: Accepted password for pi from 192.168.0.108 port 46906 ssh2
Oct 19 14:13:06 pi sshd[3082]: pam_unix(sshd:session): session opened for user pi by (uid=0)
Oct 19 14:19:28 pi sshd[3366]: Accepted password for pi from 192.168.0.108 port 44942 ssh2
Oct 19 14:19:28 pi sshd[3366]: pam_unix(sshd:session): session opened for user pi by (uid=0)
Oct 19 15:01:21 pi sshd[3546]: Connection closed by authenticating user pi 192.168.0.108 port 47032 [preauth]
Oct 19 15:01:52 pi sshd[3606]: Accepted password for pi from 192.168.0.108 port 47034 ssh2
Oct 19 15:01:52 pi sshd[3606]: pam_unix(sshd:session): session opened for user pi by (uid=0)
Oct 19 15:03:41 pi sshd[3635]: Accepted password for pi from 192.168.0.108 port 47038 ssh2
Oct 19 15:03:41 pi sshd[3635]: pam_unix(sshd:session): session opened for user pi by (uid=0)
  • You have provided no information to help solve your problem. What OS? How did you setup networking? Is Ethernet unplugged when you boot? What do ip a and ip r show? – Milliways Oct 19 at 4:55
  • Sorry, I should have written it clearly: the os is raspbian buster lite. I will edit my message to add the ip results. – Alfonso Arbona Oct 19 at 5:14
  • Networking looks OK. What happens when you enter ssh -v pi@192.168.0.105 systemctl status sshd on the Pi should show connections – Milliways Oct 19 at 5:52
  • Nothing weird, I think. I edited the question and added the logs. – Alfonso Arbona Oct 19 at 6:16
  • Looks like ssh works, but the response of environment settings (which look like a STRANGE mixture) probably confuse the client. The settings on the Pi should be reviewed. – Milliways Oct 19 at 7:02
0

It seems it was a problem with the router itself. After a full power cycle of the router it magically got fixed...

Thanks to everyone for your help!

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