Server Fault is a question and answer site for system and network administrators. 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've noticed several repeats of the following error message in /var/log/auth.log on a server:

Aug 10 09:10:16 hostname sshd[661]: error: connect_to port
25: failed.

I've changed the actual IP address, they are external addresses that often belong to mail servers.

The part I don't understand is who exactly is trying to connect to those addresses and what sshd has to do with it. The sshd is running on port 22, there is nothing running on port 25 on that server.

What exactly does this line mean, who is initiating the connection and why is sshd involved?

share|improve this question

You can reproduce this by setting up SSH dynamic port forwarding:

man ssh:

 -D [bind_address:]port
         Specifies a local “dynamic” application-level port forwarding.  This works by allocating a socket
         to listen to port on the local side, optionally bound to the specified bind_address.  Whenever a
         connection is made to this port, the connection is forwarded over the secure channel, and the
         application protocol is then used to determine where to connect to from the remote machine.  Cur‐
         rently the SOCKS4 and SOCKS5 protocols are supported, and ssh will act as a SOCKS server.  Only
         root can forward privileged ports.  Dynamic port forwardings can also be specified in the configu‐
         ration file.

         IPv6 addresses can be specified by enclosing the address in square brackets.  Only the superuser
         can forward privileged ports.  By default, the local port is bound in accordance with the
         GatewayPorts setting.  However, an explicit bind_address may be used to bind the connection to a
         specific address.  The bind_address of “localhost” indicates that the listening port be bound for
         local use only, while an empty address or ‘*’ indicates that the port should be available from all

Start a SOCKS proxy on localhost, port 2302:

$ ssh -v -ND 2302 user@host

To route HTTP traffic via this tunnel, in Firefox:

Edit -> Preferences -> Advanced -> Network tab -> Settings -> Manual Proxy Configuration -> SOCKS Host: localhost and Port: 2302

In order to make use of the SOCKS proxy with other traffic, you can use a socksifier program like tsocks:

[I] net-proxy/tsocks
     Available versions:  1.8_beta5-r3 ~1.8_beta5-r4 1.8_beta5-r5 ~1.8_beta5-r6 {tordns}
     Installed versions:  1.8_beta5-r5(10:08:28 AM 06/15/2010)(-tordns)
     Description:         Transparent SOCKS v4 proxying library

On my Gentoo, edit the /etc/socks/tsocks.conf as belows:

# Otherwise we use the server
server =
server_port = 2302


$ tsocks telnet 25

You'll see something like this in the /var/log/secure on SSH server:

sshd[28491]: error: connect_to port 25: failed.

The part I don't understand is who exactly is trying to connect to those addresses

To narrow down, take a look at the /var/log/secure (auth.log on your distro), and examine who has logged in before this:

sshd[26898]: pam_unix(sshd:session): session opened for user quanta
share|improve this answer

Setting a user's shell to /bin/false does not prevent ssh port forwarding.

So my guess is that the OP had a user login with weak or trivial password, "disabled" the account by setting shell to /bin/false or /bin/nologin, and it was exploited to send spam by ssh port forwarding.

share|improve this answer

Perhaps someone who logs in to your server is trying to establish an ssh tunnel to

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.