65-sshd remote restart failure

Moderators: kirk, jamesbond, p310don, JakeSFR, step, Forum moderators

Post Reply
user1111

65-sshd remote restart failure

Post 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.

User avatar
rockedge
Site Admin
Posts: 6539
Joined: Mon Dec 02, 2019 1:38 am
Location: Connecticut,U.S.A.
Has thanked: 2748 times
Been thanked: 2620 times
Contact:

Re: 65-sshd remote restart failure

Post 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.

user1111

Re: 65-sshd remote restart failure

Post 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 &

jamesbond
Posts: 716
Joined: Tue Aug 11, 2020 3:02 pm
Location: The Pale Blue Dot
Has thanked: 124 times
Been thanked: 402 times

Re: 65-sshd remote restart failure

Post by jamesbond »

service sshd restart & disown works for me ...

user1111

Re: 65-sshd remote restart failure

Post 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 :oops:

Post Reply

Return to “FatDog”