3

I know the problem I am going to mention can be found everywhere, but none of the solutions proposed didn't help so I decided to ask for suggestions that may lead to a solution here, specialised for my issue. Let me firstly describe my issue from the beginning:

I have a laptop which runs Ubuntu 16.04 and in which I have plugged a wifi adapter -so I can have better range from the wifi device that the laptop has- and I want to ssh to a raspberry pi 3 I have, which runs Raspbian Jessie, by using the ssh command. I am generally new to networking, so I have ran all the diagnostic commands that I have found that may show a solution to the issue and still I cannot see what maybe it's wrong. It's important to say that I have checked in both computers the ufw status and it's inactive and in both computers ssh is installed. To be more specific about the diagnostic network commands:

  • Laptop (Ubuntu 16.04):

    I have disabled the laptop's wifi device and I am only using the wifi adapter and I ran:

    ifconfig
    enp8s0    Link encap:Ethernet  HWaddr d0:bf:9c:5f:98:af  
              UP BROADCAST MULTICAST  MTU:1500  Metric:1
              RX packets:0 errors:0 dropped:0 overruns:0 frame:0
              TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
              collisions:0 txqueuelen:1000 
              RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)
    
    lo        Link encap:Local Loopback  
              inet addr:127.0.0.1  Mask:255.0.0.0
              inet6 addr: ::1/128 Scope:Host
              UP LOOPBACK RUNNING  MTU:65536  Metric:1
              RX packets:1455 errors:0 dropped:0 overruns:0 frame:0
              TX packets:1455 errors:0 dropped:0 overruns:0 carrier:0
              collisions:0 txqueuelen:1 
              RX bytes:140456 (140.4 KB)  TX bytes:140456 (140.4 KB)
    
    wlo1      Link encap:Ethernet  HWaddr d0:7e:35:7c:25:db  
              UP BROADCAST MULTICAST  MTU:1500  Metric:1
              RX packets:3523 errors:0 dropped:0 overruns:0 frame:0
              TX packets:1525 errors:0 dropped:0 overruns:0 carrier:0
              collisions:0 txqueuelen:1000 
              RX bytes:5271276 (5.2 MB)  TX bytes:150804 (150.8 KB)
    
    wlx000f600587d8 Link encap:Ethernet  HWaddr 00:0f:60:05:87:d8  
              inet addr:192.168.1.50  Bcast:192.168.1.255  Mask:255.255.255.0
              inet6 addr: fe80::b9:d1f:c83f:cc61/64 Scope:Link
              UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
              RX packets:115147 errors:0 dropped:0 overruns:0 frame:0
              TX packets:61725 errors:0 dropped:0 overruns:0 carrier:0
              collisions:0 txqueuelen:1000 
              RX bytes:169777681 (169.7 MB)  TX bytes:5747359 (5.7 MB)
    

    I also ran:

    route -n
    Kernel IP routing table
    Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
    0.0.0.0         192.168.1.1     0.0.0.0         UG    600    0        0 wlx000f600587d8
    169.254.0.0     0.0.0.0         255.255.0.0     U     1000   0        0 wlx000f600587d8
    192.168.1.0     0.0.0.0         255.255.255.0   U     600    0        0 wlx000f600587d8
    
  • Raspberry pi 3 (Raspbian Jessie):

    ifconfig 
    eth0      Link encap:Ethernet  HWaddr b8:27:eb:4d:85:d9  
              inet6 addr: fe80::10be:28c2:7983:36fe/64 Scope:Link
              UP BROADCAST MULTICAST  MTU:1500  Metric:1
              RX packets:0 errors:0 dropped:0 overruns:0 frame:0
              TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
              collisions:0 txqueuelen:1000 
              RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)
    
    lo        Link encap:Local Loopback  
              inet addr:127.0.0.1  Mask:255.0.0.0
              inet6 addr: ::1/128 Scope:Host
              UP LOOPBACK RUNNING  MTU:65536  Metric:1
              RX packets:200 errors:0 dropped:0 overruns:0 frame:0
              TX packets:200 errors:0 dropped:0 overruns:0 carrier:0
              collisions:0 txqueuelen:1 
              RX bytes:16656 (16.2 KiB)  TX bytes:16656 (16.2 KiB)
    
    wlan0     Link encap:Ethernet  HWaddr b8:27:eb:18:d0:8c  
              inet addr:192.168.1.49  Bcast:192.168.1.255  Mask:255.255.255.0
              inet6 addr: fe80::38e3:ead6:9bde:4b47/64 Scope:Link
              UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
              RX packets:20253 errors:0 dropped:3718 overruns:0 frame:0
              TX packets:12845 errors:0 dropped:0 overruns:0 carrier:0
              collisions:0 txqueuelen:1000 
              RX bytes:16856928 (16.0 MiB)  TX bytes:1841638 (1.7 MiB) 
    

    and

    route -n
    Kernel IP routing table
    Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
    0.0.0.0         192.168.1.1     0.0.0.0         UG    303    0        0 wlan0
    192.168.1.0     0.0.0.0         255.255.255.0   U     303    0        0 wlan0
    

At my laptop I ran:

ssh pi@192.168.1.49

and I get the following error after 1-2 seconds:

ssh:connect to host 192.168.1.49 port 22: No route to host

I don't know what causes this issue, so I would appreciate your suggestions and answers.

I haven't tested the laptop connection without the wifi adapter because the wifi device on my laptop doesn't work properly. So the adapter is a must, unless I use an ethernet connection between the two computers, but I want to leave this as a final option.

EDIT:

After techraf's comment:

ping 192.168.1.49
PING 192.168.1.49 (192.168.1.49) 56(84) bytes of data.
From 192.168.1.50 icmp_seq=1 Destination Host Unreachable
From 192.168.1.50 icmp_seq=2 Destination Host Unreachable
From 192.168.1.50 icmp_seq=3 Destination Host Unreachable
From 192.168.1.50 icmp_seq=4 Destination Host Unreachable
From 192.168.1.50 icmp_seq=5 Destination Host Unreachable
From 192.168.1.50 icmp_seq=6 Destination Host Unreachable
^C
--- 192.168.1.49 ping statistics ---
7 packets transmitted, 0 received, +6 errors, 100% packet loss, time 5999ms
pipe 4

I have also enabled the SSH server on the raspberry, because it was one the first solutions I found from googling my issue.

After Steve Robillard's suggestion:

sudo service ssh status
● ssh.service - OpenBSD Secure Shell server
   Loaded: loaded (/lib/systemd/system/ssh.service; enabled)
   Active: active (running) since Mon 2016-12-12 15:48:15 UTC; 1 day 20h ago
 Main PID: 545 (sshd)
   CGroup: /system.slice/ssh.service
           └─545 /usr/sbin/sshd -D

Dec 12 15:48:15 raspberrypi systemd[1]: Started OpenBSD Secure Shell server.
Dec 12 15:48:15 raspberrypi sshd[545]: Server listening on 0.0.0.0 port 22.
Dec 12 15:48:15 raspberrypi sshd[545]: Server listening on :: port 22.
Dec 14 12:36:40 raspberrypi systemd[1]: Started OpenBSD Secure Shell server.
  • You obviously saw the announcement raspberrypi.org/blog/a-security-update-for-raspbian-pixel that says ssh has been turned off by default? – SiKing Dec 12 '16 at 21:15
  • 1
    On Ubuntu ping 192.168.1.49. What are the results? Then turn off your Pi (disconnect the power cable) and again ping 192.168.1.49. What are the results? – techraf Dec 13 '16 at 0:27
  • You can confirm that SSH is running on the Pi with the following command sudo service ssh status. Please add the results of the above to your question. – Steve Robillard Dec 13 '16 at 22:59
  • Sorry for delaying my response, I reedited my answer after your suggestions. – Chris Patr Dec 14 '16 at 12:42
  • After this time is it worth to ask if you can ping its own ip-address of the two computer and if they can ping the gateway 192.168.1.1? – Ingo Feb 9 '18 at 1:31
2

To set up my headless Linux SBC's, I NEVER plug in a keyboard, mouse or display:

IMO, the easiest way to enable SSH, is to add a file, SSH (no extension) into the boot partition (also accessible via most Windows machines). Just to be safe and not waste my time, I also add a file called ssh.txt there.

You'll need network connectivity. To configure Wi-Fi, copy /etc/wpa_supplicant/wpa_supplicant.conf from an existing device or create a new wpa_supplicant.conf like:

ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
country=AU

network={
        ssid="YOUR_SSID"
        psk="YOUR_PSK"
}

and copy it into the boot partition. Note: You may want to change your county ID for compliance. Done!

1

Check if your Wi-Fi has enabled CLIENT ISOLATION in settings. This option allows all Wi-Fi clients to access internet but doesn't allow to access other clients in the local network.

If you can try to connect your laptop and your raspberry to a ethernet switch and you can ping each other, then this is the problem. If you can't connect to a ethernet switch, try to use your mobile phone to "share your connection" and use it to connect the laptop and the Raspberry to the mobile and try to ping each other.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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