RHEL 6 to manage sshd service

since we are using RHEL 6 (and CentOS 6), I wanted to test Upstart. Upstart provides a compatibility interface for SysV.

In RHEL 6, init from the sysvinit package has been replaced by Upstart, an event-based init system. It handles the starting of tasks and services during boot, stopping them during shutdown and supervising them while the system is running. For more information on Upstart itself, refer to init(8) man page.

Upstart has already been replaced in recent Fedora versions by systemd. However, it is very much “active” in RHEL6 and CentOS 6.

a) On older Linux boxes, I used the following for sshd in /etc/inittab:

mssh:2345:respawn:/usr/sbin/sshd -D

This would ensure that an ssh daemon process was always kept running even if the system experienced extreme conditions (OOM, out of memory, overcommitted memory, and so on), or a killall which kills the running daemon. As long as init can function, it will keep the sshd running.

This is particularly handy for systems that are co-located and do not have reliable serial port console connections.

b) And here is the solution that works on RHEL 6 and CentOS 6.

Create file in /etc/init/ssh.conf.

# ssh
#
# This service starts sshd.

start on runlevel [2345]
stop on runlevel [!$RUNLEVEL]

kill timeout 30
console output
respawn
exec /usr/sbin/sshd -D


As soon as sshd daemon dies, Upstart forks a new one.
SHARE

sangeethakumar

  • Image
  • Image
  • Image
  • Image
  • Image
    Blogger Comment
    Facebook Comment

0 comments:

Post a Comment