I cannot SSH into my server via the terminal. So far I've tried:

ssh root@ip-address and ssh username@ip-address

but neither has worked. I'm getting a blank screen for a while and then eventually

operation timed out

I've also tried switching to a different location with a different Internet Service Provider, so I'm fairly sure that the problem isn't a firewall.

I can login via FTP.

This is what I get:

$ ssh hosting-account-username@ip-address
ssh: connect to host ip-address port 22: Operation timed out

I've also tried this with no result:

$ nc ip-address 22

I've pinged the address:

$ ping ip-address
64 bytes from ip-address icmp_seq=143 ttl=45 time=44.543 ms
64 bytes from ip-address icmp_seq=143 ttl=45 time=43.686 ms
64 bytes from ip-address icmp_seq=143 ttl=45 time=46.501 ms
-- and so on 

My hosting company has told me I do have SSH, but on port 2222 (instead of 22) because I have a shared hosting account and tried this:

$ nc ip-address -p [2222]
nc: missing hostname and port
usage: nc [-46AacCDdEFhklMnOortUuvz] [-K tc] [-b boundif] [-i interval]
          [-p source_port] [--apple-delegate-pid pid] [--apple-delegate-uuid uuid]
          [-s source_ip_address] [-w timeout] [-X proxy_version]
          [-x proxy_address[:port]] [hostname] [port[s]]

$ ssh username@ip-address:2222
ssh: Could not resolve hostname ip-address:2222: nodename nor servname provided, or not known

Not sure what else to try.

  • The problem is most likely one of - routing issue (does ping work?) or a firewall issue or the SSH server us not rubbing or us not listening on the correct interface.
    – davidgo
    Dec 28, 2018 at 0:35
  • @JimDanner in fact, the connection DOES NOT work. We know this because the operation times out rather then being closed.
    – davidgo
    Dec 28, 2018 at 1:47
  • @davidgo Well, the IP connection works (there’s a response to the ping), but obviously the ssh connection doesn’t. I agree there can still be multiple causes.
    – Jim Danner
    Dec 28, 2018 at 1:55
  • @Chameleon With FTP, you could download /etc/ssh/sshd_config and see if there are lines that don’t start with a # that reveal anything interesting.
    – Jim Danner
    Dec 28, 2018 at 2:04
  • I've cropped the whitespace from the screenshots, but in the future you can just copy & paste plain text from a terminal (use the Code / CTRL-K formatting). Also, I'm not sure about your ssh, but mine has the -p [port] option, so adding -p 2222 might solve your problem. Or ssh user@address:port
    – Xen2050
    Dec 28, 2018 at 3:02

3 Answers 3


The -p option in nc command is for source port and you need to specify destination port.

Try $ nc ip-address 2222 to check if you can reach the port.

Also I don't think than ssh command accept the syntax hostname:port.

Try $ ssh -p 2222 username@ip-address instead.

  • scp -p 2222 localfile user@host:/file/path and ssh -p 2222 user@host remotecommand Dec 28, 2018 at 11:01
  • @SampoSarrala With scp, the port option uses capital P: scp -P 2222 user@host...
    – Kenster
    Dec 28, 2018 at 16:44

It is rather common to run the ssh service on a non-default port to prevent brute force attacks, etc. so you need to specify the (correct!) port number. If you aren't sure what this is, you can check with your service provider or if you have some other method of accessing the service with sudo netstat -ltnp | grep ssh

To connect, assuming you are using port 2222

ssh -p 2222 user@host

Will work. For scp or sftp, the option changes to upper case so

scp -P 2222 user@host:/path/to/remote/file /path/to/local/destination

If you are on a *nix system (Mac included) you can edit ~/.ssh/config and create profiles that handle the various port options, etc.

Host webhost
    HostName www.example.com
    Port 2222
    User webmaster
    IdentityFile ~/.ssh/www-private-key

And then simply connect via ssh webhost since the webhost profile specifies hostname, port number, user, etc. for the connection.


What worked for me was to use ssh user@IP -p 2222. Was asked for the password, got in right away.

  • This is what this other answer advised few hours ago. If this works for you, you should accept the other answer instead of writing your own that only duplicates the solution. Please take our short tour to learn Super User is not a forum. I think your answer should be deleted, unless you have something new to add (if so, edit the answer). Dec 28, 2018 at 19:09
  • I have accepted the answer - but I would like to point out that you can also type -p 2222 after user@IP instead of before it. So ssh user@IP -p 2222 and ssh -p 2222 user@IP will both work.
    – Chameleon
    Dec 28, 2018 at 20:20

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .