8

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
  • 1
    what happens if you ssh user@ipaddress? – wlraider70 Aug 3 '15 at 0: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
7

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

| improve this answer | |
  • What can I do if it fails ssh user@ipaddress ? – abu abu Mar 7 '17 at 6:19
  • 1
    Check the connection from 1 machine to other by pinging. ping 192.168.1.2 for example. Use the same ip you are trying to connect to. If you can't ping you cant connect. – wlraider70 Mar 7 '17 at 14:31
4

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

sudo ufw allow ssh
| improve this answer | |
2

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

| improve this answer | |
0

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
| improve this answer | |

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.