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

OK!!! I've successfully connected from an external network on both ssh and http. I changed a BUNCH of settings though before I got it to work, so I'm going to slowly change some of them back to see where the problem(s) really was(were).

Thanks for all the suggestions!!!

This ought to be a pretty simple answer, but I can't find it anywhere, and it's really confusing me. I am new to Ubuntu, and am trying to configure a web server. I have gone through tons of tutorials, and run into "host" or "localhost" very often. For example, to execute ssh user@localhost, I would replace user with my username, and localhost with my internal IP address (connecting from the same local network). That much, I can do.

I just want to make sure that all I have to do is replace host with my external (ISP provided) IP address to ssh from an outside network??? The thing is that I have done that, and it hasn't worked, so I want to make sure that my syntax isn't the problem. Thanks so much for your patience and support.

Ok. Everyone's saying I need to forward ports. I did forward ports 80 and 22 through my router to my server, but it's not working. I also contacted my ISP, and they said that they didn't know of any ISP restrictions on ports. So, yes. I think I set it up, but it's still not working. Also, I completely bypassed my router, and connected my server directly to the modem, which does NOT have an internal router, and the problem was still there. Since somebody upvoted this question, I can now post my pic :)enter image description here

share|improve this question
Did you remember to forward port 22 to your Ubuntu server? – Cry Havok Aug 23 '12 at 20:29
Yes, I've tried to set that up. I was going to post a screen shot of my router config page, but apparently I need two more rep in order to get that permission... – Casey Hungler Aug 23 '12 at 20:36
Do you try to connect to your external IP from inside the LAN? This doesn't work usually. Try that from outside of your local network. – Sergey Aug 23 '12 at 20:40
no, I did it from a cell phone with WiFi disabled, so that it would have to go through cell network, and gave external IP to a friend and had them try. I know it doesn't work from inside, because I have that set up to go to router config... – Casey Hungler Aug 23 '12 at 20:43
How do you determine your external IP? How does it look like (give us 2 first numbers at least). Can you be using a wrong IP or an IP from your internal network by mistake? – Sergey Aug 23 '12 at 21:04
up vote 0 down vote accepted

From other answers and comments, I think your ip forward problem looks solved so coming back to the original question about host and localhost: yes, in this case, host is your external IP. Usually, host means any host (ip or hostname or url), internal or external depending on the situation and localhost is not any internal IP but the IP of the machine you are working on (lo interface - IP and provided you have something like localhost.localdomain localhost (or only localhost as is the default) in /etc/hosts you can let it as localhost without substitution.

For example you can:

ping localhost and (your machine loopback interface - lo) should answer.

share|improve this answer

You need to forward a port used by SSH (22) on your router so all traffic coming on that port from outside is redirected to your Ubuntu machine.

See this article: or search for "forward port router".

Once you have port forwarding correctly configured, you'll be able to use your external IP address, or any DNS name configured to point to that IP address, to connect to your Ubuntu box from outside. The IP is the most robust way to do this. So, in your case, you need to replace (host) in (user)@(host) with your external IP address.

Also, as I said, getting proxy errors suggests that there's a proxy in the middle, which shouldn't be there. Which suggests that something is mis-configured.

share|improve this answer
Thanks, I actually already used that tutorial, and many others, to try to get port forwarding set up. It says it is set up, but is not working. In ssh, I get a timeout error, and through http, I get error 502 bad gateway. bad response from proxy server or destination server... – Casey Hungler Aug 23 '12 at 20:40
I don't think that's the problem. I've connected the server directly to the modem, without a router at all, and it still didn't work. With that setup, wouldn't all traffic be sent directly to the server, without any forwarding? – Casey Hungler Aug 23 '12 at 21:00
Is your modem an old-style "dumb" modem which is connected to the computer via something which is not a LAN cable? These days modems often act as routers, i.e. you can plug multiple devices into the modem and the devices will be able access Internet and each other - maybe you need to set up port forwarding on your modem? Please describe what "connected the server directly to the modem" means – Sergey Aug 23 '12 at 21:11
My modem is a centurylink 660. It has a phone jack and a LAN cable. I think I just found its config page, and it seems that it has at least a firewall... I'm going to try adjusting that. If i need to port forward from my modem, which is only connected to my router, do I forward to my router @ so that my router can forward to my server? – Casey Hungler Aug 23 '12 at 21:23
"connected the server directly to the modem" means that I took the LAN cable coming out of the modem (the one that typically feeds the router) and plugged it into the back of the server. – Casey Hungler Aug 23 '12 at 21:46

Ok. To answer my original, official question, refers to the external IP address (ISP provided), and refers to the internal IP address. There is no extra punctuation necessary, and you do not need to include the internal IP address when entering , as that should be setup through port forwarding.

Now, the solution to my problem was not really a solution, but several solutions. It turns out that my configuration of my ROUTER was correct, and as determined in a previous question, we knew that my SERVER firewall was configured properly because I was able to access my home page and my server through ssh while on the LOCAL network. The big problem was with my MODEM; I had already set up a sort of port forwarding in my modem, but it was not configured properly to route to my router. Also, I had to make my modem's firewall accept WAN to LAN communication. In addition to updating these settings, which still needed to be done, I am sorry to admit that I switched the locations of two numbers in my external IP address.

All that said, I really appreciate everyone's participation, as your comments helped me to find the modem configuration, which ultimately lead me to the correction of my erroneous IP address, and the multiple necessary solutions to my problem, which has been plaguing me for three days now...

share|improve this answer

In short, it refers to the computer. Host is usually used in the context of networking.

share|improve this answer
Yeah, I also started explaining what "host" means, but if you re-read the question you'll see that the OP actually wants to know about port forwarding :) – Sergey Aug 23 '12 at 20:38
Well, the problem I am having is with port forwarding, yes. In order to work towards solving that problem, however, I am looking for the proper syntax of what "host" should be replaced with. Nobody has corrected me yet, so I'm assuming that I was correct in assuming that it is just the IP address, and then we can determine that the problem must somehow be with port forwarding. – Casey Hungler Aug 23 '12 at 20:50

SSH server binds to certain network interfaces (which usually refer to network cards in a computer).

So, checkout you /etc/sshd_config for

Port 22

The port should be 22 and ListenAddress should be commented out.

The second step I would take is to ckeck if you can connect to your ssh server through the interface your system is conected to the router.

Post here the output of ifconfig iа you don't know how to do that and I'll help you.

ps also is there any firewall enabled in your system?

share|improve this answer
well, /etc/sshd_config does not exist, however /etc/ssh/sshd_config does, and is configured as itshoudl be. – Casey Hungler Aug 23 '12 at 21:41
what about The second step ? – zuba Aug 23 '12 at 21:45
eth0 Link encap:Ethernet HWaddr 00:13:d4:21:23:5d inet addr: Bcast: Mask: inet6 addr: fe80::213:d4ff:fe21:235d/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:23462 errors:0 dropped:0 overruns:0 frame:0 TX packets:1103 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:3946492 (3.9 MB) TX bytes:98004 (98.0 KB) – Casey Hungler Aug 23 '12 at 21:47
lo Link encap:Local Loopback inet addr: Mask: inet6 addr: ::1/128 Scope:Host UP LOOPBACK RUNNING MTU:16436 Metric:1 RX packets:320 errors:0 dropped:0 overruns:0 frame:0 TX packets:320 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:25341 (25.3 KB) TX bytes:25341 (25.3 KB) – Casey Hungler Aug 23 '12 at 21:48
try ssh to right from the shell – zuba Aug 23 '12 at 21:48

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.