Page 1 of 1
65-sshd remote restart failure
Posted: Wed Jun 01, 2022 8:02 am
by user1111
/etc/init.d/65-sshd ... restart choice, runs through a ... stop; sleep 1; start ... sequence. However if invoked remotely, via ssh, then after the stop the link is disconnected and the start isn't invoked, leaving the 'remote' system with no sshd running and you can't ssh back into to start it
One option to fix that might be to have a sub-directory beneath /etc/init.d, where a script to stop/restart sshd is nohup/background invoked within 65-sshd when the restart option is being run.
Re: 65-sshd remote restart failure
Posted: Wed Jun 01, 2022 10:39 am
by rockedge
maybe a cron job script that checks for the sshd PID and when missing restarts the sshd server. Invoke the cron job in remote connection scenerios.
Perhaps a script in /root/Startup will suffice to restart the sshd server when a remote restart is triggered.
Re: 65-sshd remote restart failure
Posted: Wed Jun 01, 2022 3:11 pm
by user1111
I was thinking more like having a script in a init.d/sub-initd ... type folder that 65-sshd invoked with a nohup or exec and background action, or where 65-sshd restart section might be modified to something like ...
cat <<EOF >/tmp/restartsshd
#!/bin/sh
killall sshd
sleep 1
/usr/sbin/sshd
rm /tmp/restartsshd
EOF
chmod +x /tmp/restartsshd
nohup /tmp/restartsshd &
Re: 65-sshd remote restart failure
Posted: Wed Jun 01, 2022 3:40 pm
by jamesbond
service sshd restart & disown
works for me ...
Re: 65-sshd remote restart failure
Posted: Wed Jun 01, 2022 7:41 pm
by user1111
jobs
[1]+ Stopped .......... brain
... along comes James and bg % 1
Bet-ya that come next time I want to restart sshd remotely it will be brain sleeping/stopped again