So I am able to SSH onto the server when connected to the same network, but I need to enable remote connection.

When I enter ssh -v user@serverIP, I get the output:

OpenSSH_5.6p1, OpenSSL 0.9.8y 5 Feb 2013
debug1: Reading configuration data /etc/ssh_config
debug1: Applying options for
debug1: Connecting to [] port 22.

When i enter ssh user@serverIP i get:

ssh: connect to host port 22: Host is down

I enabled port22 forwarding with :

sudo ufw allow 22

I also logged onto my router firewall settings to enable port 22.

The main things I changed in /etc/ssh/sshd_config is:

Port 22
ListenAddress InternetIP
ListenAddress ServerIP

Any insight would be greatly appreciated.

  • I think you have mistaken the ListenAdddress syntax. It's not a |-separated list of IPs. Use multiple ListenAddress lines with an IP/hostname per line. – muru Dec 3 '14 at 23:01
  • Thank you @muru I edited it as: Listen address:serverIP – atavel Dec 3 '14 at 23:04
  • and another line: ListenAddress hostIP – atavel Dec 3 '14 at 23:05
  • 1
    atavel: the other part to consider is that you will also need port forwarding if your 'server ip' resides behind NAT (like a firewall or router device). – Thomas Ward Dec 3 '14 at 23:07
  • 1
    @atavel that only works at the server itself, do you have a router between the server and the internet at all? – Thomas Ward Dec 3 '14 at 23:09

Perhaps I'm missing something, but nowhere in your question do I see a "remote" IP address. I only see 192.168.x.x, which is only available inside your lan. If you want to connect from outside the lan, you need to use an external (public) address, which is the real address as seen from the outside. If it's a dynamic address, you either need to make sure it is current, or use a dynamic DNS service such as DynDNS.

Also, you need to open the port on your router, and make sure it's directed to the server for port 22.

Added Information

If you want easy outside access to one or more servers on your system, you might want to look into Dynamic DNS. There are free services that require periodic access or perhaps other requirements. The one I use (dyndns.org) used to have a free service, but now costs $25/year. I use it for remote access to a web server, and also my calibre ebook server. It allow you to choose a domain name from a big list, and add a prefix to make it personal. For example, you can choose homelinux.net, and add any number of names, such as "atavel.homelinux.net"; you run a standard updater periodically on your home system that will read your actual ip address, and update dynDNS in case of change. It's not very complicated, really.

  • Thank you @Marty_Fried . I have found my public IP (beginning with 104.xxx.xx.xxx). Does that need to be entered in sshd.config after ListenAddress as well? Or where is it needed? (I'm new to networking!) – atavel Dec 3 '14 at 23:27
  • 1
    Got it! I didn't realize that I just needed to enter ssh user@publicIP Thank you! – atavel Dec 3 '14 at 23:32
  • Glad you got it to work. I updated my answer with some information about dynamic DNS, in case you might be interested. It makes it easier to access your home servers, especially if the ip address changes. – Marty Fried Dec 4 '14 at 0:04

Thanks to muru for this part

Firstly, the ListenAddress syntax is not a pipe-separated list. You'll need two lines. For example:

Port 22
ListenAddress InternetIP
ListenAddress ServerIP

The next consideration point is that you need to use port forwarding if your server is behind NAT or a router. This will need to be configured at your router or firewall device, in order to get from the Internet (Public) IP to the internal (private) IP address of your server.

NOTE: This is NOT the same as an 'allow' rule in the firewall on the server.

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.