LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   SSHD start on boot problem... (https://www.linuxquestions.org/questions/linux-software-2/sshd-start-on-boot-problem-34200/)

Cephlen 10-30-2002 03:53 PM

SSHD start on boot problem...
 
Hello,

I am having a small problem getting sshd to startup on boot (it works if I run it manually).

sshd is not listed under my "services" section in the mandrake control center.

Doing a service sshd start gives me "Extra argument start" but it doesnt startup the sshd service.

Doing a chkconfig --add sshd gives me "service sshd does not support chkconfig"

In my init.d directory is a sshd file, but its a binary file - not a script. I dont know if this is normal or not.

There are no s??sshd ln's in my rc?.d directories.

I am running Mandrake 9.0 and compiled ssh version 3.5p1 using md5 and pam options. I tried using the included rpm with Mandrake9, but couldnt get it to work.

Thanks in advance..

nonamenobody 10-30-2002 06:38 PM

>> In my init.d directory is a sshd file, but its a binary file - not a script. I dont know if this is normal or not.


Normal? Not in any distro I've ever used, init should be just that scripts. This is particularly true if your system uses insserv, in order to change what runlevel a service runs at when, you use inserv, the comments at the top of the file need to be edited (obviously not possible). This seems very unusual to me, though I haven't used Mandrake in a while.

I have just checked the openssh rpm on a mandrake 9 cd, the file '/etc/rc.d/init.d/sshd' is an init script.

neo77777 10-30-2002 07:16 PM

Suppose the installed sshd is under /usr/local/sbin/sshd, make a symlink in /etc/rc?.d to point to /usr/local/sbin/sshd
cd /etc/rc3.d
ln -sf /usr/local/sbin/sshd S##sshd
pick ## somewhere in mid 20's to 50's, I believe it's ok, repeat for any runlevel you are likely to boot
don't forget to create K links in rc0.d and rc6.d to shutdown sshd daemon gracefully

neo77777 10-30-2002 07:41 PM

Sorry for a little confusion, above might not work because of "extra argument" error, create /etc/init.d/sshd script containing
Code:

!/bin/sh
# Start/stop/restart the secure shell server:

sshd_start() {
  # Create host keys if needed.
  if [ ! -r /etc/ssh/ssh_host_key ]; then
    /usr/bin/ssh-keygen -t rsa1 -f /etc/ssh/ssh_host_key -N ''
  fi
  if [ ! -f /etc/ssh/ssh_host_dsa_key ]; then
    /usr/bin/ssh-keygen -t dsa -f /etc/ssh/ssh_host_dsa_key -N ''
  fi
  if [ ! -f /etc/ssh/ssh_host_rsa_key ]; then
    /usr/bin/ssh-keygen -t rsa -f /etc/ssh/ssh_host_rsa_key -N ''
  fi
  /usr/sbin/sshd
}

sshd_stop() {
  killall sshd
}

sshd_restart() {
  if [ -r /var/run/sshd.pid ]; then
    echo "WARNING: killing listener process only.  To kill every sshd process, you must"
    echo "        use 'rc.sshd stop'.  'rc.sshd restart' kills only the parent sshd to"
    echo "        allow an admin logged in through sshd to use 'rc.sshd restart' without"
    echo "        being cut off.  If sshd has been upgraded, new connections will now"
    echo "        use the new version, which should be a safe enough approach."
    kill `cat /var/run/sshd.pid`
  else
    killall sshd
  fi
  sleep 1
  sshd_start
}

case "$1" in
'start')
  sshd_start
  ;;
'stop')
  sshd_stop
  ;;
'restart')
  sshd_restart
  ;;
*)
  echo "usage $0 start|stop|restart"
esac

and make symlinks in /etc/rc?.d/ to point to /etc/init.d/sshd
ln -sf ../init.d/sshd S##sshd
and in runlevel 0 and 6
ln -sf ../init.d/sshd K##sshd
It should work, sorry for confusion, didn't think clearly :)
P.S. the script is taken from stock slackware ssh install, substitute the path to sshd daemon and you'll be alright

Cephlen 10-31-2002 03:50 PM

neo77777, thank you very much!

I edited your script to my paths, created those ln's... and PRESTO!


All times are GMT -5. The time now is 08:13 AM.