Ubuntu – Can not access ssh server from outside

ssh

We are using ubuntu 10.04 LTS server.I can ssh access that server from other ubuntu machine in own network. But when we are trying to access the server from out side of LAN we are unable to ssh connect.I can give the outputs :
starlite@starlite-laptop:~$ nmap -A -T4 192.168.1.46

Starting Nmap 5.00  at 2011-05-20 14:03 IST
Interesting ports on 192.168.1.46:
Not shown: 996 closed ports
PORT     STATE SERVICE    VERSION
22/tcp   open  ssh        OpenSSH 5.3p1 Debian 3ubuntu5 (protocol 2.0)
|  ssh-hostkey: 1024 00:12:34:45:56:67:78:89:9070:91 (DSA)
|_ 2048 5d:96:00:12:34:45:56:67:78:89:90:36:70:91:a6 (RSA)
5001/tcp open  apc-agent  APC PowerChute agent
5432/tcp open  postgresql PostgreSQL DB
8080/tcp open  http       Apache Tomcat/Coyote JSP engine 1.1
|_ html-title: Apache Tomcat
Service Info: OS: Linux; Device: power-device

Service detection performed. Please report any incorrect results at http://nmap.org/submit/ .
Nmap done: 1 IP address (1 host up) scanned in 8.35 seconds

but when nmap from a different global IP the output is

starlite@starlite-laptop:~$ nmap 122.XXX.XXX.XXX -p 22 

Starting Nmap 5.00  at 2011-05-20 16:50 IST
Interesting ports on 122.XXX.XXX.XXX:
PORT   STATE  SERVICE
22/tcp closed ssh
The ssh connection is terminated as shown below - 
starlite@starlite-laptop:~$ ssh openbravo@122.176.65.178
ssh: connect to host 122.XXX.XXX.XXX port 22: Connection refused

please help me how can I overcome this problem

Best Answer

Did you check if the IP for the server is Class C (Local Network) or has an Internet IP. If it is local you will not be able to connect to it except rerouting from the Internet IP assign to that network.

Class C IP are for example: 192.168.0.1 (Common one used in cafes) 192.168.1.10 and tipically any 192.168.X.X

In your question the ip 192.168.1.46 is Class C which is not accessible by normal means except rerouting connections.

The other ip 122.XXX.XXX.XXX is an Internet IP which will work

What i recommend is telling the router that connects to the Internet (The one that has the 122.XXX.XXX.XXX) to redirect all connections to that port to the 192.168.1.46 IP in the network.

Related Question