Hi i am not able start the sshd on redhat 6.9. Here is the logs
When i try restarting service i get following error logs.
/var/log/messages
Mar 5 06:49:31 c2t26451 init: sshd main process (19225) terminated with status 255
Mar 5 06:49:31 c2t26451 init: sshd main process ended, respawning
/var/log/secure
Mar 5 07:37:54 c2t26451 sshd[31840]: error: Bind to port 22 on 0.0.0.0 failed: Address already in use.
Mar 5 07:37:54 c2t26451 sshd[31840]: fatal: Cannot bind any address.
Here is the service status and sshd process
[ ~]$ sudo service sshd status
openssh-daemon is stopped
[ ~]$ ps -ef|grep ssh
root 22036 28601 0 05:26 ? 00:00:00 sshd: testuser [priv]
testuser 22042 22036 0 05:26 ? 00:00:00 sshd: testuser@pts/0
testuser 22166 22043 0 05:29 pts/0 00:00:00 grep ssh
root 28601 1 0 Mar05 ? 00:00:00 /usr/sbin/sshd -D
Though one process is already running and i am wondering if i kill it i would be locked out of server permanently. Also i am not sure if i reboot the server how the effect would.
Best Answer
The reason you don't see it as a service, is that sshd is running as a regular process instead of service/daemon. From
man sshd
:You can check if any other network services are using the same port by issuing
netstat
command:What you could do is create another sshd config file with a different name and different port number. Remember to open that port in iptables. Start the other instance with new config specified:
This will start sshd the same way, as a process. Connect via ssh on your new port number and kill the other session - make sure you're killing the right one! Also, keep the first session opened just in case.
Now start your default sshd as a service, not a daemon and enable it to start with system boot.
Now, as per your further comments: It seems, that something is restarting sshd when killed. Might be its own config file or sshd itself, if I understand correctly (again, referring to
man sshd
):Questions to OP:
Would you mind posting your sshd config file, preferably with all sensitive details "censored"? Is it a fresh OS install or a server that you "inherited"?
Update:
I've ran a simple test, because that
-D
option got me thinking: it should not detach and run in the background.If I kill this process from another session or
Ctrl-c
in the session where i ran/usr/sbin/sshd -D -f test_sshd
, normal behaviour is this process closes and does not restart.This would suggest that you have some other process, script, watchdog running that is restarting sshd as a regular process when it fails, gets killed or exits in other kind of way. Please look into your
cron
oranacron
entries as root user, check running processes forscreen
ortmux
.