Erratic sshd start

General support questions
Post Reply
billwest
Posts: 154
Joined: 2006/11/19 10:50:31
Location: Perth, Western Australia

Erratic sshd start

Post by billwest » 2019/05/23 01:14:08

HI,

I have a Centos 7 (fully updated) running, but not 24/7.
When I boot the system, I generally log in to it (Putty ssh) from my desktop PC (Win7).
However, I am not always successful in doing so. Quite often the sshd service isn't running, even though I have set it to start at boot time.
I then need to use Webmin to start the ssh server. I am then able to log in.
At other times it will work as expected.

I have used:

chkconfig sshd on
systemctl enable sshd

however this behaviour does not change.
What am I missing?

Thanks,

Bill.

User avatar
TrevorH
Site Admin
Posts: 33216
Joined: 2009/09/24 10:40:56
Location: Brighton, UK

Re: Erratic sshd start

Post by TrevorH » 2019/05/23 06:20:21

On CentOS 7 systemd is in use that starts services in parallel rather than in series (as was the previous case). On my systems I often find that the system appears to be up and running with a login prompt on the console but that ssh is not accessible immediately. It takes up to a minute for it to start and be listening. Are you sure you're waiting long enough?

If you are then you are going to have to go and read your logs. Look at the output from systemctl status sshd before you restart it.
The future appears to be RHEL or Debian. I think I'm going Debian.
Info for USB installs on http://wiki.centos.org/HowTos/InstallFromUSBkey
CentOS 5 and 6 are deadest, do not use them.
Use the FAQ Luke

billwest
Posts: 154
Joined: 2006/11/19 10:50:31
Location: Perth, Western Australia

Re: Erratic sshd start

Post by billwest » 2019/05/23 06:42:22

Thanks Trevor, that could be it.
I am sometimes able to log in via ssh after a while (upto 10 mins).
I'll give it some more time. I have looked at log files but see nothing untoward.
However, your explanation of services starting in parallel tells me a lot.

Bill.

User avatar
TrevorH
Site Admin
Posts: 33216
Joined: 2009/09/24 10:40:56
Location: Brighton, UK

Re: Erratic sshd start

Post by TrevorH » 2019/05/23 09:13:18

10 minutes sounds excessive.
The future appears to be RHEL or Debian. I think I'm going Debian.
Info for USB installs on http://wiki.centos.org/HowTos/InstallFromUSBkey
CentOS 5 and 6 are deadest, do not use them.
Use the FAQ Luke

billwest
Posts: 154
Joined: 2006/11/19 10:50:31
Location: Perth, Western Australia

Re: Erratic sshd start

Post by billwest » 2019/05/28 00:56:40

Yesterday, after more than an hour, I still could not ssh to the server.
I have tried this with firewall on and off, no difference.

User avatar
TrevorH
Site Admin
Posts: 33216
Joined: 2009/09/24 10:40:56
Location: Brighton, UK

Re: Erratic sshd start

Post by TrevorH » 2019/05/28 08:41:54

So, time to go read all your logs then and try to work out why.
The future appears to be RHEL or Debian. I think I'm going Debian.
Info for USB installs on http://wiki.centos.org/HowTos/InstallFromUSBkey
CentOS 5 and 6 are deadest, do not use them.
Use the FAQ Luke

billwest
Posts: 154
Joined: 2006/11/19 10:50:31
Location: Perth, Western Australia

Re: Erratic sshd start

Post by billwest » 2019/05/29 12:03:31

Log files duly inspected in great detail.
All they revealed was "Deprecated option RSAAuthentication".

So I commented out the relevant entry for that in sshd_config.
I also set "UseDNS no".

So far so good.

User avatar
TrevorH
Site Admin
Posts: 33216
Joined: 2009/09/24 10:40:56
Location: Brighton, UK

Re: Erratic sshd start

Post by TrevorH » 2019/05/29 12:18:28

I would expect a config file syntax error etc to lead to a completely unstartable sshd. I suspect it's more likely that your network takes a while to come ready and obtain an ip address and that sshd starts before it's complete and fails to bind.

Have you explicitly listed an ip address to bind to in the sshd config? If so then perhaps that might be the cause - if it's told to listen on any interface/ip address then it will do so and will bind to e.g. localhost at startup. If you specify an ip address to listen on that's on an interface that takes a while to become ready (STP?) and sshd starts before the network interface has that ip then it will fail.
The future appears to be RHEL or Debian. I think I'm going Debian.
Info for USB installs on http://wiki.centos.org/HowTos/InstallFromUSBkey
CentOS 5 and 6 are deadest, do not use them.
Use the FAQ Luke

billwest
Posts: 154
Joined: 2006/11/19 10:50:31
Location: Perth, Western Australia

Re: Erratic sshd start

Post by billwest » 2019/06/05 09:37:00

Seems the problem is solved - I disabled sshd.socket.

aks
Posts: 3073
Joined: 2014/09/20 11:22:14

Re: Erratic sshd start

Post by aks » 2019/06/05 18:27:18

Eh? The fundamental part of the sshd process (listen for connections) is the problem? Suspect not. Suspect there's other things lurking beneath. Making a listening socket is the root problem. Hmmmm.

Post Reply