WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

Author Topic: openssh init.d restart  (Read 2501 times)

Offline hiro

  • Hero Member
  • *****
  • Posts: 1229
openssh init.d restart
« on: March 07, 2013, 12:42:11 PM »
Sometimes my sshd doesn't restart properly. that's quite bad especially for ssh cause that's the only way of accessing some machines.
I suspect it's because pidof tries to kill not only the main sshd, but also processes from logins that might not even exist any more after killing the main sshd, so pidof gives back bad status.

stop(){                                                                                                             
   kill $(pidof sshd)                                                                                               
}                                                                                                                   
                                                                                                                     
restart(){                                                                                                           
   if pidof sshd >/dev/null; then                                                                                   
      stop && start                                                                                                 
   else                         
      start                     
   fi                           
}                               

Offline Len

  • Newbie
  • *
  • Posts: 14
Re: openssh init.d restart
« Reply #1 on: May 06, 2013, 09:45:45 PM »
I ran into this problem today and made a change in my openssh init.d script:

stop()
{
   pkill /usr/local/sbin/sshd
}

the only draw backs of this solution are that:
1. we assume pkill is available to us.
2. the full pathname is hardcoded -- although it appears the rest of the init.d script assumes the same.

hope that helps

Offline gerald_clark

  • TinyCore Moderator
  • Hero Member
  • *****
  • Posts: 4254
Re: openssh init.d restart
« Reply #2 on: May 07, 2013, 12:58:06 AM »
Why?
pkill is in /usr/bin and is part of busybox.

Offline Len

  • Newbie
  • *
  • Posts: 14
Re: openssh init.d restart
« Reply #3 on: May 07, 2013, 01:31:12 AM »
Hi gerald_clark,

I'm not sure if your "Why?" was directed at my comments or not, but if it was I was merely stating some assumptions I made and pointing out possible faults to my suggestion so that Hiro had some information to make a decision on using my suggestion or not.

Len

Offline Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11634
Re: openssh init.d restart
« Reply #4 on: May 07, 2013, 01:34:57 AM »
Hi Len
Gerald_clark was merely pointing out that  pkill  is always available.