12

I have trouble connecting to a server with ssh from my Lubuntu 14.04 computer, although it can be done from other machines. I can't get to the address online either (others can).

Am currently using a 3G network from my phone, but this doesn't seem to be the problem as I can connect to the server using another computer with the same 3G connection.

This is my attempt to connect:

root@Elizabeth:/# ssh USER@HOSTNAME
ssh: connect to host HOSTNAME port 22: Connection timed out

UPDATE: Saw that ping HOSTNAME renders the wrong IP-address, so I guess this could be a clue to what's wrong. Any way to solve that? I can get around it though by doing ssh USER@IPADDRESS, as suggested to me in a comment.

Some further info below, if it's useful. I'm new to working with servers and networking, so do say if there is other information needed to say what is wrong.

root@Elizabeth:/# nm-tool | grep "DNS"
DNS: 172.20.10.1
DNS: 172.20.10.1

root@Elizabeth:/# nslookup HOSTNAME
Server:        127.0.1.1
Address:    127.0.1.1#53

Non-authoritative answer:
Name:    HOSTNAME
Address: IP-address # correct IP-address for HOSTNAME

root@Elizabeth:/# ip route
default via 172.20.10.1 dev eth1  proto static 
172.20.10.0/28 dev eth1  proto kernel  scope link  src 172.20.10.3  metric 1 
172.20.10.0/28 dev wlan0  proto kernel  scope link  src 172.20.10.5  metric 9
Ingrid
  • 371
  • 2
    what happens if you ssh user@ipaddress? – wlraider70 Aug 03 '15 at 00:22
  • That solved it - thanks a lot! Wasn't more complicated than that. I tried that earlier, but with the wrong IP-address, since I thought it'd be the IP-address that was shown when doing ping hostname, but that actually gave the wrong IP address for some reason. – Ingrid Aug 16 '15 at 12:05

5 Answers5

9

Allow ssh to ufw will solve the problem. Run the below command to allow.

sudo ufw allow ssh
Rafiqul Islam
  • 191
  • 1
  • 5
9

To properly test your ssh use ssh user@ipaddress. If that fails, the issue is something like the firewall.

For example, checkout firewall status with below code

sudo ufw status

If it is working then first deactivate firewall with below code:

sudo ufw disable

and test ssh user@ipaddress

Thomas
  • 6,223
Viral Nakrani
  • 111
  • 1
  • 6
8

To properly test your ssh use ssh user@ipaddress. If that fails, the issue is something deeper like the connection.

Ingrid
  • 371
wlraider70
  • 1,683
1

Allow ssh and port 22 from ufw, then enable it and check with status command

sudo ufw allow ssh
sudo ufw allow 22
sudo ufw enable
sudo ufw status
Tahirhan
  • 111
-1

please go to the Network setting, choose the Ethernet connection and disable all Ethernet connection only connect to the Wi-fi. after that go to your terminal and write ssh username@ipaddress (ssh stackoverflow@161.10.10.1)

  • 2
    Using a different connection makes no sense and isn't in any way possible related with the question. The only useful part of this answer is a copy of the other answers. – ChanganAuto Mar 21 '22 at 20:52