1

I have two laptops and one desktop computer at my home, all running Ubuntu 18.04. Openssh-server and ssh is installed on each of them. However, I am unable to login from one of them onto another of them; e.g., when on the computer with hostname Machine-1, an attempt to login to Machine-2 using:

ssh <mylogin-name>@Machine-2 

fails. I've tried editing /etc/hosts, and files in /etc/ssh. I think my problem should be easy to solve; help greatly appreciated.

$ ssh -v saul@NullA-3
OpenSSH_7.6p1 Ubuntu-4ubuntu0.1, OpenSSL 1.0.2n  7 Dec 2017
debug1: Connecting to nulla-3 [192.168.1.5] port 22.
debug1: connect to address 192.168.1.5 port 22: No route to host
ssh: connect to host nulla-3 port 22: No route to host
8
  • 1
    Hi, this is not the right way to use ssh. Try the following: ssh username@Machine-2. The "username" part should be a valid user on Machine-2. Dec 16, 2018 at 16:31
  • Sorry; I actually typed: ssh <myusername>@Machine-2. Dec 16, 2018 at 20:07
  • and it doesn't work. Dec 16, 2018 at 20:10
  • So, I still would greatly appreciate help. -- Saul Dec 16, 2018 at 20:11
  • 1
    "No route to host" is a routing problem. Can you ping the other system?
    – waltinator
    Dec 17, 2018 at 4:32

4 Answers 4

3

Trying to log in to a non-existing IP address,

$ ssh [email protected]
ssh: connect to host 192.168.1.11 port 22: No route to host

Trying to log in to my [local] server at an existing IP address,

$ ssh [email protected]
[email protected]'s password: 

No route to host indicates that the IP address is wrong or that there is a problem with the LAN, for example that the router is not working or configured correctly.


You can install and use arp-scan to scan for the connected IP and MAC addresses,

sudo apt update
sudo apt install arp-scan

sudo arp-scan -lv  # minus ell vee
1

The problem is solved. The command

ssh username@machine-2

always worked. I had stupidly been trying to get it to work, when machine-2 was dormant -- e.g., when the laptop was closed; or when machine-2 was sleeping.

I've found the utility nmap quite useful for this; the command

nmap -sn 192.168.1.0-24

gives a lot of useful information about the local network.

0
0

connect to address 192.168.1.5 port 22: No route to host

Seems like this is a router/network issue.

Instead of ping i suggest using more advanced utility:

mtr 192.168.1.5

I can also suggest checking you router settings, and assigning static ip for both computers.

P.S. The exact steps how to do that depend on the router model. I can suggest checking the sticker on the router itself, there is usually a model number.

1
  • How do I check my router settings; and how do I assign static ip for all three computers (two laptops, one desktop; all running Ubuntu 18.04)? (There is also a fourth object on the small network: An epson inkjet printer). Dec 17, 2018 at 18:15
0

First of all you should check if all computers are in same network.

  • Go to each computer, run terminal and type ifconfig, you will see IP address on each computer.
  • Are You connected to same network on each computer? (same WIFI/cable?)

Using nmap

If it's not installed:

$ sudo apt install nmap

then

$ nmap -sP 192.168.0.0/24
$ nmap -sP 192.168.1.0/24 
# This command depends on Your network configuration. Check it with `ifconfig`

Below is an example on my network:

felixd@docker:~$ ifconfig 
enp0s3: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.10.15  netmask 255.255.255.0  broadcast 192.168.10.255
        inet6 fe80::a00:27ff:fe26:bbd1  prefixlen 64  scopeid 0x20<link>
        ether 08:00:27:26:bb:d1  txqueuelen 1000  (Ethernet)
        RX packets 908  bytes 1173342 (1.1 MB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 678  bytes 50398 (50.3 KB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
  • inet 192.168.10.15 netmask 255.255.255.0 broadcast 192.168.10.255

In my case I would use nmap this way as my IP address is 192.168.10.15

$ nmap -sP 192.168.10.15/24 

Netmask is 255.255.255.0 so I use /24 in nmap command to check whole local network.

My output:

felixd@docker:~$  nmap -sP 192.168.10.15/24 

Starting Nmap 7.60 ( https://nmap.org ) at 2018-12-22 21:24 CET
Nmap scan report for 192.168.10.1
Host is up (0.0019s latency).
Nmap scan report for 192.168.10.2
Host is up (0.0021s latency).
.
.  Lot of other devices ;)
.
Host is up (0.049s latency).
Nmap scan report for 192.168.10.82
Host is up (0.0014s latency).
Nmap done: 256 IP addresses (12 hosts up) scanned in 15.13 seconds

Now I know that 192.168.10.82 is my Ubuntu server I can try to login to this machine:

$ ping 192.168.10.82 ;) to check if it's alive ;)

then

$ ssh [email protected]

Good luck. Cheers, Paweł.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .