Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I've installed open-ssh-server on my home computer(running Lubuntu 12.04.1) in order to connect to it from school. This is how I've set up the sshd_config file:

# Package generated configuration file
# See the sshd_config(5) manpage for details

# What ports, IPs and protocols we listen for
#Port 22
Port 2222
# Use these options to restrict which interfaces/protocols sshd will bind to
#ListenAddress ::
Protocol 2
# HostKeys for protocol version 2
HostKey /etc/ssh/ssh_host_rsa_key
HostKey /etc/ssh/ssh_host_dsa_key
HostKey /etc/ssh/ssh_host_ecdsa_key
#Privilege Separation is turned on for security
UsePrivilegeSeparation yes

# Lifetime and size of ephemeral version 1 server key
KeyRegenerationInterval 3600
ServerKeyBits 768

# Logging
SyslogFacility AUTH
#LogLevel INFO

# Authentication:
LoginGraceTime 120
PermitRootLogin no
StrictModes yes

RSAAuthentication yes
PubkeyAuthentication yes
#AuthorizedKeysFile %h/.ssh/authorized_keys

# Don't read the user's ~/.rhosts and ~/.shosts files
IgnoreRhosts yes
# For this to work you will also need host keys in /etc/ssh_known_hosts
RhostsRSAAuthentication no
# similar for protocol version 2
HostbasedAuthentication no
# Uncomment if you don't trust ~/.ssh/known_hosts for RhostsRSAAuthentication
#IgnoreUserKnownHosts yes

# To enable empty passwords, change to yes (NOT RECOMMENDED)
PermitEmptyPasswords no

# Change to yes to enable challenge-response passwords (beware issues with
# some PAM modules and threads)
ChallengeResponseAuthentication no

# Change to no to disable tunnelled clear text passwords
#PasswordAuthentication yes

# Kerberos options
#KerberosAuthentication no
#KerberosGetAFSToken no
#KerberosOrLocalPasswd yes
#KerberosTicketCleanup yes

# GSSAPI options
#GSSAPIAuthentication no
#GSSAPICleanupCredentials yes

X11Forwarding no
X11DisplayOffset 10
PrintMotd no
PrintLastLog yes
TCPKeepAlive yes
#UseLogin no

#MaxStartups 10:30:60
#Banner /etc/
Banner /etc/

# Allow client to pass locale environment variables
AcceptEnv LANG LC_*

Subsystem sftp /usr/lib/openssh/sftp-server

# Set this to 'yes' to enable PAM authentication, account processing,
# and session processing. If this is enabled, PAM authentication will
# be allowed through the ChallengeResponseAuthentication and
# PasswordAuthentication.  Depending on your PAM configuration,
# PAM authentication via ChallengeResponseAuthentication may bypass
# the setting of "PermitRootLogin without-password".
# If you just want the PAM account and session checks to run without
# PAM authentication, then enable this but set PasswordAuthentication
# and ChallengeResponseAuthentication to 'no'.
UsePAM yes

#specify which accounts can use SSH
AllowUsers onlyme

I've also configured my router's port forwarding table to include:

  • LAN Ports: 2222-2222
  • Protocol: TCP
  • LAN IP Address: "IP Address" displayed by viewing "connection information" from right-click menu of system tray
  • Remote Ports[optional]: n/a
  • Remote IP Address[optional]: n/a

I've tried various other configurations as well, using primary and secondary dns, and also with specifying remote ports 2222-2222. I've also tried with TCP/UDP (actually two rules because my router requires separate rules for each protocol).

With any router port forwarding configuration, I am able to log in with

ssh -p 2222 -v localhost

But, when I try to log in from school using

ssh -p 2222 onlyme@IP_ADDRESS 

I get a "No route to host" message. Same thing when I use the "Broadcast Address" or "Default Route/Primary DNS". When I use the "subnet mask", ssh just hangs. However, when I use the "secondary DNS" I recieve a "Connection refused" message.


Someone please help me figure out how to make this work.

share|improve this question
Have you tried using the default SSH port 22? Sometimes it's stupid things that get something blocked. Although your School may block SSH connections in general. Have you tried SSH'ing into your Home PC from another location besides your School? Try connecting from a McDonalds, Starbucks, etc... I've always had success from locations like those. If it does work than most likely it's not you but your School's network. They may have blanket restrictions on the network. There are some more covert ways of tunnelling so we can try that if SSH won't work. – japzone Dec 5 '12 at 4:26
Also did you make sure you're using your External IP Address and not your Internal one? – japzone Dec 5 '12 at 4:29
Yes, I was initially using port 22 but switched to 2222 after reading some other forum posts similar to mine.I can't try from another network because I don't have another computer to use as the client in that situation. – wulfsdad Dec 5 '12 at 5:04
Android and iOS both have SSH clients as well. Android I recommend ConnectBot and on iOS the only Free Option I found was SolarWinds Mobile Admin Client. – japzone Dec 5 '12 at 15:10

Once you can connect to the machine from inside your LAN, the rest is completely outside of the control of Ubuntu running on that machine. So the problem is likely to be somewhere outside of your Ubuntu box. Possible causes may include:

  • incorrectly configured port forwarding on your router. Note that the internal IP of your machine may change when you reboot it, especially if you have more than one device in your LAN, it may depend on the order addresses are requested from the router's DHCP. You can use ifconfig command in the console to see your IP address.

  • you using an incorrect IP when trying to connect from outside (actually, "No route to host" message strongly suggests that). Google "what is my ip" to find one of many sites which will tell you what your current external IP is. Note your external IP may change if you reboot the router.

  • As a "security measure", some providers block incoming connections to their client's ports - either all ports or a range of well-known ports. There may be some setting in the ISP's control panel or you may need to call them to figure this out.

So the way to debug the problem would be:

  • make sure you can connect from within LAN
  • make sure you correctly configured port forwarding on the router using the correct internal IP of your machine
  • figure out your external IP
  • make sure you can ping that IP, use traceroute to see where the packets are blocked
  • possibly try configuring forwarding for some "easier" service, such as HTTP first to exclude problems with authentication etc.

(also, I'm not sure why you're mentioning DNS stuff - everything is done via plain IP addresses, DNS has absolutely nothing to do with it)

share|improve this answer
When I use traceroute, with any of the addresses, I receive a "unknown host" message. I mentioned the DNS stuff because its listed in the system-tray-->connection_information and I tried everything there because I don't know which is the one to use. I had assumed that the "secondary DNS" was my external IP, because it gave me the best results. But when I googled "what is my ip" It listed another address different from anything else I've used. I tried it, and ssh just hung. – wulfsdad Dec 5 '12 at 5:23
@wulfsdad: if the connection hangs it means that the IP address you're using may be correct, but the packets are silently dropped either by your router (in case it's not configured correctly) or by your ISP's equipment. To some extent, you can use traceroute to diagnose that – Sergey Dec 5 '12 at 6:19
What does it mean if traceroute reports the host is unknown? – wulfsdad Dec 5 '12 at 6:39

Reading your comments I think part of the problem is that you're using the wrong IP. DNS is the Internet Phonebook, not your External IP. Go to and type "ip" in the search. Google will tell you your External IP.

Also go to a Library and use one of their computers, download the Portable Putty client HERE(Run the Installer and choose the Desktop as the Install Location, It will extract the Files to a Folder, the just run PuttyPortable.exe) and then use it to try and Connect to your Home PC. Make sure to delete it after your done with it because most Libraries don't like it when you download programs to their PCs(but they won't check anyway).

There are also Online SSH clients that will give you a free 5 minute session so you can try those from the Home PC itself. Although you may want to change your Password temporarily before you attempt so for security reasons.

share|improve this answer
up vote 0 down vote accepted

I finally figured out what was wrong: I didn't know anything about TCP/IP. I was using the wrong IP. Since my IP is dynamic, I made a script to dump it into a dropbox folder. So I can retrieve it from school and log in.

#!/usr/bin/perl -w

use strict;
use LWP::Simple;

open( OFILE, ">/home/username/Dropbox/home.txt" ) || die "opening file $!";
print OFILE get("");
close( OFILE );
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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