2

When I'm connected to my school network, I am able to ssh into my desktop computer at home just fine from my laptop. But when I'm home, trying to ssh into the same desktop from the same laptop always gives me time out error:

ssh: connect to host <my IP address> port 22: Connection timed out

I enabled port forwarding on port 22 in my router, installed openssh and everything is set up so that I'm able to ssh when I'm at school.

On my home desktop, the command

sudo netstat grep | grep sshd 

returns

tcp   0   0   0.0.0:22     0.0.0.0:*    LISTEN   sshd

I do not understand why this won't work outside my school network. Currently when I ssh into my home desktop computer from my laptop connected to my school network, I'm using the IP address of my desktop.

MORE INFO:

when I run

ssh -vv <myusername>@<my-ip-address>

I get

OpenSSH_6.6.1, OpenSSL 1.01f 6 Jan 2014
debug1: Reading configuration data etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: Applying for options for *
debug2: ssh_connect: needpriv 0
debug1: Connecting to <IP address> [<IP address>] port 22.
debug1: connect to address <IP address> port 22: Connection timed out

closed as off-topic by user68186, Pilot6, Eric Carvalho, waltinator, user364819 Jun 18 '17 at 19:59

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "This is not about Ubuntu. Questions about other Linux distributions can be asked on Unix & Linux, those about Windows on Super User, those about Apple products on Ask Different and generic programming questions on Stack Overflow." – Pilot6, Eric Carvalho, waltinator, Community
If this question can be reworded to fit the rules in the help center, please edit the question.

  • 1
    School may be using NAT. Your school desktop IP may not be accessible from outside the school's LAN. Alternately school may be blocking, using a firewall, external ssh connections. You may have to troubleshoot this one with your school's IT guys. – user68186 Jun 16 '17 at 2:13
  • hmm okay. I'll contact the IT guys and see if they can solve this. Thank you. – MoneyBall Jun 16 '17 at 5:25
4

Based on your responses to numerous questions, the actual configuration is:

Desktop is at your school. You can ssh into it from your laptop when your laptop is connected to the school network.

You cannot connect your laptop to the school workstation desktop when your laptop is outside the school network.

It is highly unlikely that the workstation in your lab has a static registered Internet reachable IP address. Or even one issued by DHCP. In addition, connections could be going through a NAT translation before packets go onto the Internet which means that the machines IP address inside the school will be different from the IP address that's visible outside the school. Plus, various incoming port requests such as 22 could be blocked by a firewall.

Any issues there would need to be resolved by the school IT staff. They can create a static NAT entry in their border router so that you will know what IP to ssh into from the Internet. They may or may not be willing to do this.

In the meantime, as a handy tool to troubleshoot problems like this, install nmap on your laptop.

sudo apt-get install nmap

Then, from home or somewhere outside of school,

ping The.IP.you.think.connects.to.your.machine.from.the.Internet

nmap The.IP.you.think.connects.to.your.machine.from.the.Internet

If ping returns nothing or if nmap doesn't show that port 22 is open you'll never be able to ssh into it. For the reasons mentioned above, it's possible that nmap isn't actually probing YOUR machine so if ssh fails to authenticate, that could well be the reason.

Needless to say, you need to know the IP address that's visible from the Internet that will connect to your desktop workstation at school. And nothing such as a firewall can be blocking the ssh connection dialog. If that is the root of your issue, open that up as a new question since it doesn't have anything (directly) to do with why ssh doesn't work.

To find out your Internet IP address, on the desktop workstation at school go to this URL:

http://whatismyipaddress.com/
  • It should be made known that it is entirely possible the school does not permit this and therefore is why they NAT things. Most smaller schools (not universities) fall into the category of places that don't permit this kind of thing anyways. – Thomas Ward Jun 16 '17 at 16:19
1

Your attempt to ssh into the school network might be blocked because the IP address cannot be reached from outside.

Ask your school IT folks if you can: first ssh into your school firewall/DHCP (with a static IP), then from their ssh into whatever IP address you want. They will provide correct public IP and private credentials if the school policy allows.

0

The IP address of the machine you are trying to ssh into from your home LAN is different than the Internet facing IP address of your router.

If you do a traceroute to your home desktop / ssh server from school, you'll see that the packet goes to your router and is then forwarded to the ssh host which is on your local LAN and on the other side of the router.

From your home network you are directly connected to the same LAN as the Desktop / ssh server. That is, your laptop IP and your desktop machine / ssh server IP will be on the same subnet.

If you ssh into the 192.168.0.x (or whatever) local address of the desktop / ssh server from home, that should work.

To find out your desktop / ssh server's local address:

ifconfig -a
  • I don't understand. Isn't 192.168.0.x local address which can only be accessed when you're in the same network? I am using DDNS that I registered in my router to access my desktop. – MoneyBall Jun 16 '17 at 1:45
  • Your question indicates that you are having problems connecting from a laptop connected to your home LAN to a desktop running as an ssh server that is also on your home LAN. Try as I suggested and that should work. If this is not the case you need to re-word your question. Or open a new question. – jones0610 Jun 16 '17 at 1:50
  • oh no the server is in school network and my home LAN is separate. – MoneyBall Jun 16 '17 at 1:51
  • Please add the results of your desktop / ssh server ifconfig -a I'm assuming it does not have a registered IP address. – jones0610 Jun 16 '17 at 2:14
  • no, i do have registered ip. I am using DDNS – MoneyBall Jun 16 '17 at 5:25

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