Ask Your Question
0

ssh port 22 connection refused

asked 2013-09-06 01:25:33 -0600

Nagaraju gravatar image

updated 2013-09-10 22:47:51 -0600

I am getting an error

ssh: connect to host 10.5.6.206 port 22: Connection refused

when I am trying to login from a remote machine using LAN.It used to work fine earlier but changed since the selinux configuration was changed from enforcing to permissive.

output of ssh -v :

 OpenSSH_5.6p1, OpenSSL 1.0.0j-fips 10
 May 2012 debug1: Reading configuration
 data /etc/ssh/ssh_config debug1:
 Applying options for * debug2:
 ssh_connect: needpriv 0 debug1:
 Connecting to xx.x.x.xxx [xx.x.x.xxx]
 port 22. debug1: connect to address
 xx.x.x.xxx port 22: Connection refused ssh: connect to host xx.x.x.xxx port
 22: Connection refused
edit retag flag offensive close merge delete

Comments

@Nagaraju What if you switch back SELINUX to enforcing? Can you do that on target machine ed ssh -v one more time?

ztank1013 gravatar imageztank1013 ( 2013-09-06 02:58:46 -0600 )edit

Even then I get the same error

Nagaraju gravatar imageNagaraju ( 2013-09-06 03:22:34 -0600 )edit

@Nagaraju I guess it is not a SELINUX issue then. Are you able to login to the target server in some way?

ztank1013 gravatar imageztank1013 ( 2013-09-06 04:23:52 -0600 )edit

No as your answer suggests sshd daemon is not running.How should I fix it.when I do /etc/init.d/sshd start it says "Job failed. See system logs and 'systemctl status' for details."

Nagaraju gravatar imageNagaraju ( 2013-09-06 05:19:33 -0600 )edit

On the server (10.5.6.206) - does systemctl status sshd.service say anything interesting? Anything in /var/log/messages telling why sshd does not start? Do: /usr/sbin/sshd - this will print (if) any configuration errors in /etc/ssh/sshd_config

marcindulak gravatar imagemarcindulak ( 2013-09-06 10:57:49 -0600 )edit

3 Answers

Sort by ยป oldest newest most voted
1

answered 2013-09-10 02:49:27 -0600

Nagaraju gravatar image

updated 2013-09-10 02:50:31 -0600

Thanks for your replies.I got the solution. When I did check the output of

/usr/sbin/sshd -D -d

debug1: sshd version OpenSSH_5.6p1

debug1: read PEM private key done:

type RSA debug1: private host key: #0

type 1 RSA debug1: read PEM private

key done: type DSA debug1: private host key: #1 type 2 DSA

/var/empty/sshd must be owned by root and not group or world-writable.

Directory permissions messed up when I was trying to execute a perl script in /var/www/cgi-bin/.

So when I changed back the permissions back to 755(rwx rx rx) ssh works fine now.

edit flag offensive delete link more
2

answered 2013-09-06 02:49:35 -0600

ztank1013 gravatar image

It looks like either the sshd daemon is no longer running on the target server or the port is closed (maybe the firewall?).

edit flag offensive delete link more
1

answered 2013-09-06 10:12:11 -0600

baptistemm gravatar image

What does return nc -z -w 3 10.5.6.206 22; echo $? if 1 it means you don't have any SSH server running on the machine.

edit flag offensive delete link more

Question Tools

Stats

Asked: 2013-09-06 01:25:33 -0600

Seen: 14,442 times

Last updated: Sep 10 '13