SSH : Connection Refused

1

1

I have a shared hosting account on hostgator.
When i do SSH to that server via Port 2222 then i get

"Connection Refused"

error

P.S:- 2222 is SSH port for shared hosting accounts on hostgator.

Is it because of my ISP blocking this port ?
Is there a way to confirm this ?

on another note :- i am able to ssh on standard port 22 to a VM created on microsoft azure cloud.

P.S: i am a networking noob :-)

UPDATE:-

nmap <server ip address> 

It returns below

Host is up (0.078s latency).   
Not shown: 989 filtered ports  
PORT     STATE SERVICE  
21/tcp   open  ftp  
25/tcp   open  smtp  
53/tcp   open  domain  
80/tcp   open  http  
110/tcp  open  pop3  
143/tcp  open  imap  
443/tcp  open  https  
587/tcp  open  submission   
993/tcp  open  imaps  
995/tcp  open  pop3s   
3306/tcp open  mysql   

UPDATE 2:-
i am able to do ssh on hostgator through my azure VM.
so it looks like an issue with my ISP.
also if i do nmap <server ip address> from azure VM

it returns below

Host is up (0.0061s latency).    
Not shown: 976 closed ports   
PORT     STATE    SERVICE   
1/tcp    filtered tcpmux   
3/tcp    filtered compressnet   
4/tcp    filtered unknown   
6/tcp    filtered unknown   
7/tcp    filtered echo   
9/tcp    filtered discard  
13/tcp   filtered daytime  
17/tcp   filtered qotd  
19/tcp   filtered chargen  
21/tcp   open     ftp  
22/tcp   filtered ssh   
25/tcp   open     smtp    
26/tcp   open     rsftp  
53/tcp   open     domain   
80/tcp   open     http   
110/tcp  open     pop3   
143/tcp  open     imap  
443/tcp  open     https   
465/tcp  open     smtps   
587/tcp  open     submission   
993/tcp  open     imaps   
995/tcp  open     pop3s   
2222/tcp open     unknown  
3306/tcp open     mysql   

So now this one shows ssh in open port..

harrybvp

Posted 2014-01-06T19:59:52.957

Reputation: 163

1What is the output for nmap server_ip_address ? – user2196728 – 2014-01-06T20:44:54.127

i have updated my question – harrybvp – 2014-01-06T20:56:47.820

And me my answer ;) – user2196728 – 2014-01-06T20:58:18.777

You could try option -v to put ssh in verbose mode and get more detailed messages. Multiple -v parameters increase verbosity. My favorite tool to test port reachability is netcat (nc). – Axel Kemper – 2014-01-06T21:04:29.497

check your sshd configuration - needs to specify 2222 as a listen port in the server configuration. You also may have another listener using 2222, perhaps a proxy or NI scanner. You could shut down SSH and see if there's still something on the port. – lonstar – 2014-01-06T21:42:17.933

1Given the suspicion that your ISP is blocking port 2222, you could try a service like ismyportopen.com: insert your server's IP address, and then ports 22 and 2222. This will reach your server from outside your ISP network. – MariusMatutiae – 2014-01-07T02:22:27.363

@MariusMatutiae i tried ismyportopen.com and it says Port 2222 is opened on my hostgator server..also i am able to ssh on hostgator server through another machine (azure VM) ...so this proves My ISP has blocked this 2222 Port..I will check with my ISP – harrybvp – 2014-01-07T13:49:18.597

Answers

2

Try nmap -p 2222 <server ip> to scan port 2222 specifically since "By default, Nmap scans the most common 1,000 ports for each protocol."

That will tell you if you can see a port 2222 open on the server.

If it is open, then there is something wrong on the server configuration that is preventing your client from connecting to sshd. sshd might not be running, might be misconfigured, etc.

If it is closed then either the server is configured to filter the port or you are having trouble reaching that port on the server. To identify which, you will need to test the connection from another machine (different ISP perhaps? ask a friend--if it works then check your firewall/isp, else, probably something remote) or try to connect to another server's port 2222 (if your ISP is filtering outgoing connections on tcp 2222).

arcyqwerty

Posted 2014-01-06T19:59:52.957

Reputation: 968

It shows '2222/tcp filtered unknown'...so i guess definitely issue with my ISP – harrybvp – 2014-01-06T21:12:05.677

Could be that 2222 is blocked on the server end; you should check from another computer/network to be sure. Alternatively, if you have a different external server with ssh on 2222 you could test that as well. – arcyqwerty – 2014-01-06T21:14:08.443

1

Regarding your nmap result i would say :

Port 22 and port 2222 are not available.

It can be an ISP issue (blocking port 2222 as you mentionned) or a misconfig from Hostgator.

I would ask each of them for this issue !

user2196728

Posted 2014-01-06T19:59:52.957

Reputation: 1 146

as i mentioned in my question ,i have shared hosting account,so ssh port is 2222 (not 22)..although i tried with both the ports and it does not work. – harrybvp – 2014-01-06T20:33:27.030

0

Given that it seems likely your ISP is blocking port 2222, and that the best advice is: Change ISP, the second best piece of advice I can offer is to use port 443 on your server as your SSH port.

In my experience, port 443 is the least likely to be blocked by any ISP, after port 80, of course. So you might just tell your /etc/ssh/sshd_config to use port 443 instead of 2222, on your server, and on your client modify your ~/.ssh/config file to include these lines:

  Host Your_SSH_server_IP
    Port 443
    IdentityFile /home/yourname/.ssh/private_crypto_key_for_SSH_server

I think it may be worth a try, in any case.

MariusMatutiae

Posted 2014-01-06T19:59:52.957

Reputation: 41 321

Unfortunately I am using 'Shared Hosting' on Hostgator..They don't allow to change SSH Port :-( – harrybvp – 2014-01-07T19:32:04.940

@harrybvp Can you run an iptables command to redirect from one port (443) to 2222? If you can then, iptables -t nat -A PREROUTING -s your_own_ip_address -p tcp --dport 443 -j REDIRECT --to-ports 2222 should do it. – MariusMatutiae – 2014-01-07T19:45:44.037

it required sudo access ...when i ran it .i got "<username> is not in the sudoers file. This incident will be reported" :-( – harrybvp – 2014-01-07T20:18:34.997