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 have ubuntu 12.04 and I am trying to connect to my SSH server remotely, I get authentication denied because the password is incorrect. However, when I connect to my machine from my local network i.e., and I use the same exact password I used when logging remotely, I connect to my ssh machine correctly .. .any help with that ??

share|improve this question

Make sure that your router doesn't have an SSH server running and forward the port 22 to your SSH server.

To make sure that your router isn't running SSH, get the local IP of your router using netstat -nr. Here is what I get:

netstat -nr
Kernel IP routing table
Destination     Gateway         Genmask         Flags   MSS Window  irtt Iface         UG        0 0          0 eth0   U         0 0          0 eth0

Find the gateway, for me it is Next, try connecting to it through ssh:


If it asks for username&password, then it has an SSH server. You should be able to disable it from the router's web panel (accessible with the IP we have aquired).

Then, you'll need to forward the port 22 to your SSH server with your router's web panel (accessible with the IP we have aquired).

share|improve this answer
no there is no SSH server on the router I know that and I have checked it now again. I feel like the SSH server on ubuntu is like configured to accept connections only from the local network. I don't know how is this ... but this is what I feel. Is there anyway I can like show the configuration ? or any other ideas u got that might help me ?? – I.el-sayed Nov 19 '12 at 2:48
Guys please any help with this problem ?? – I.el-sayed Nov 19 '12 at 22:03
Do check your /etc/ssh/sshd_config – Terry Wang Nov 20 '12 at 8:37

You can try running the client and server with more verbosity See this answer: Can't Login to my Server via SSH, and the password is correct

Also check if there is a line like "AllowUsers username@ip"

share|improve this answer

I don't think this is the best way, but it works

sudo nano /etc/ssh/sshd_config

inside change port to 39 (any, not 22):

Port 39

save and restart ssh:

sudo service ssh restart

when connect use -p 39:

ssh developer@ -p 39
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.