18

I'm new to using ssh and related technologies, so it's very possible I'm not understanding something basic. (This also might be a question for Server Fault instead....not sure.)

I'm trying to ssh into a web server (that I own) and the connection is never established due to timeout.

~ $ ssh -vvv DOMAIN.com
OpenSSH_6.2p2, OSSLShim 0.9.8r 8 Dec 2011
debug1: Reading configuration data /Users/USER/.ssh/config
debug1: Reading configuration data /etc/ssh_config
debug1: /etc/ssh_config line 20: Applying options for *
debug1: /etc/ssh_config line 102: Applying options for *
debug2: ssh_connect: needpriv 0
debug1: Connecting to DOMAIN.com [123.45.67.89] port 22.
debug1: connect to address IPADD port 22: Operation timed out
ssh: connect to host DOMAIN.com port 22: Operation timed out

My first thought was that I had somehow specified the domain wrong, or that something was wrong with my site. So I tried connecting to the same domain via FTP, and that worked fine (was prompted for user name):

~ $ ftp
ftp> open
(to) DOMAIN.com
Connected to DOMAIN.com.
220---------- Welcome to Pure-FTPd [privsep] [TLS] ----------
220-You are user number 2 of 50 allowed.
220-Local time is now 12:47. Server port: 21.
220-This is a private system - No anonymous login
220-IPv6 connections are also welcome on this server.
220 You will be disconnected after 15 minutes of inactivity.
Name (DOMAIN.com:USER):

So then I thought maybe I was just using SSH wrong. I started watching this tutorial video. At about 1 minute in he does ssh will@supercars.com and gets a username prompt, but it gives me the same timeout as above. I then tried ssh google.com which does the same. ssh localhost, on the other hand, works fine. So the problem seems to be something to do with SSH requests over a network.

My next thought was that it may be a firewall issue. I do have Sophos installed on this machine, but according to my administrator it "should not" block outgoing SSH requests.

Can anyone help figure out why this is happening?

  • 7
    That is a live IP address you're giving us. It has an unsecured FTP connection running on it. This might not be a good idea. It also does not have anything running on port 22, which I suspect is the source of your problems. You can't just ssh into anything, the server needs to have an sshd running, this one doesn't seem to. If it's your server, turn ssh on and turn ftp off. You can do ftp over ssh once it's running. – marinus Sep 13 '15 at 17:11
  • 3
    No need to delete. I have edited the IP out and have asked SE to purge the edit history. That way, the person who answered you doesn't loose any reputation. – terdon Sep 13 '15 at 18:00
23

That error message means the server to which you are connecting does not reply to SSH connection attempts on port 22. There are three possible reasons for that:

  1. You're not running an SSH server on the machine. You'll need to install it to be able to ssh to it.
  2. You are running an SSH server on that machine, but on a nonstandard port. You need to figure out on which port it is running; say it's on port 2222, you then run ssh -p 2222 hostname.
  3. You are running an SSH server on that machine, and it does use the port on which you are trying to connect, but the machine has a firewall that does not allow you to connect to it. You'll need to figure out how to change the firewall, or maybe you need to ssh from a different host to be allowed in.

EDIT: as (correctly) pointed out in the comments, the third is certainly the case; the other two would result in the server sending a TCP "reset" package back upon the client's connection attempt, resulting in a "connection refused" error message, rather than the timeout you're getting. The other two might also be the case, but you need to fix the third first before you can move on.

  • 4
    If it weren't installed, or if it were running on a different port, then he would be getting connection refused messages. – Hut8 Sep 13 '15 at 23:05
  • 2
    @Hut8: Is right. Of your 3 possibilities, only the third one (firewall) could possibly lead to timeouts. – R.. Sep 14 '15 at 4:17
  • On Ubuntu: sudo ufw allow 22; do your work then; sudo ufw deny 22. digitalocean.com/community/tutorials/… – Daniel Mar 15 '18 at 22:20
3

Check by telnet command whether you're able to connect to SSH port 22. If you are not able to connect then check for it. First you should be able to connect on port no. 22 to server.

By default SSH port is 22. But if you have configured any other port then use that port instead of 22.

telnet < ip/url of server> < port>

e.g. telnet domain.com 22

  • 2
    This will time out just the same (otherwise the ssh -v log would've shown a connection succeeded, rather than saying it timed out) – Wouter Verhelst Sep 13 '15 at 21:50
  • @Wouter Verhelst yeah, thnx for clarification – AVJ Sep 14 '15 at 5:44
  • How can you check which port is configured? Configure a new port? – Yonatan Simson Mar 23 '17 at 8:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.