0

I have a raspberrypi3 connected to my home network via ethernet cable. I am trying to access it via ssh from a laptop connected to the same network over wi-fi.

I enabled ssh on the pi's user (which has a different name than the default pi). When I try to connect with ssh <user>@<ip-address> I still get ssh: connect to host <ip-address> port 22: No route to host

Could it be because the pi is connected to the home network via ethernet? Or should I set something in the router?

I tried to pin the pi's ip address and this is what I get

64 bytes from 192.168.1.102: icmp_seq=371 ttl=64 time=2.46 ms
64 bytes from 192.168.1.102: icmp_seq=372 ttl=64 time=2.04 ms
64 bytes from 192.168.1.102: icmp_seq=373 ttl=64 time=2.17 ms
64 bytes from 192.168.1.102: icmp_seq=374 ttl=64 time=3.77 ms
etc. etc.

Which makes me think the laptop and pi are indeed connected.

Any ideas?

p.s: I also created an empty ssh file in /boot

EDIT 20/12/2017

I did some additional testing. I connected the raspberry via wi-fi and ssh works correctly. I then disconnected from wi-fi by commenting out the lines regarding my ssid and psw in /etc/wpa_supplicant/wpa_supplicant.conf. I connected the raspberry via ethernet cable and can see its internal IP in the page of my router. I use ssh <user>@<ip-address> -vv and this is what I get:

OpenSSH_7.2p2 Ubuntu-4ubuntu2.2, OpenSSL 1.0.2g  1 Mar 2016
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: Applying options for *
debug2: resolving "192.168.1.4" port 22
debug2: ssh_connect_direct: needpriv 0
debug1: Connecting to 192.168.1.4 [192.168.1.4] port 22.
debug1: connect to address 192.168.1.4 port 22: No route to host
ssh: connect to host 192.168.1.4 port 22: No route to host
  • 1
    Not an answer, so I post my remark as a comment: If ping works, but ssh does not, I would look outside of the Raspberry Pi. My guess would be the router, which seems to block TCP between wireless and wired. If ssh is disabled on the Raspberry Pi, you would see a different message anyway ("Connection refused", as far as I remember). – Martin Dec 17 '17 at 18:42
  • I am trying to look around my router's configuration panel but I cannot see anything that would enable the wired/wireless communication. Nor I can find any guide/thread talking about it. Any idea how I would address that? – Fede9390 Dec 17 '17 at 19:27
0

Check your laptop firewall. It may allow ping through but not ssh. ping uses port 7, ssh uses port 22.

Also Some routers from ISPs have multiple Wifi networks. Make sure your laptop is not on a 5G Wifi network.

  • On my laptop I have gallium os (based on ubuntu).. I do not think it has a firewall installed – Fede9390 Dec 18 '17 at 19:47
0
  1. Check whether your ssh daemon is up and running and listens on all interfaces. Execute following command as user pi on your Raspberry

    sudo netstat -tulpen | grep ssh

You should get something like

tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      0          7805        2897/sshd       
tcp6       0      0 :::22                   :::*                    LISTEN      0          7807        2897/sshd 
  1. Check whether it's a firewall issue.

Execute following command on your laptop:

nc -vn 192.168.1.102 22

You should get something like

Connection to 192.168.1.102 22 port [tcp/*] succeeded!
SSH-2.0-OpenSSH_7.4p1 Raspbian-10+deb9u2
  • I do get both results correctly.. does that mean both tests were fine and the problem is something else? – Fede9390 Dec 18 '17 at 19:42
  • If both tests succeed you should use option -v or even option -vv when connecting to Raspi. Check the verbose output of the ssh client for error messages. – framp Dec 19 '17 at 19:27
  • I did and edited my question with the result – Fede9390 Dec 20 '17 at 12:14

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