Monit: Monitor SSHD Server and Auto Restart SSH If It Does Not Respond
Q. How do I monitor my ssh server with monit? How do I restart ssh server if it does not respond or dead due to any issues under Linux?
A. You can easily monitor Linux server or service such as OpenSSH (SSHD daemon) using monit utility.
Monitor SSH and Auto Restart If Died
Open your /etc/monitrc or /etc/monit/monitrc file:
# vi /etc/monit/monitrc
Append following code:
check process sshd with pidfile /var/run/sshd.pid
start program "/etc/init.d/ssh start"
stop program "/etc/init.d/ssh stop"
if failed port 22 protocol ssh then restart
if 5 restarts within 5 cycles then timeout
Save and close the file. Make sure you set /var/run/sshd.pid and /etc/init.d/ssh as per your Linux distribution. These values are valid for Debian / Ubuntu Linux. Restart monit to pickup the changes:
# /etc/init.d/monit restart
E-mail this to a friend
Printable version
Related Other Helpful FAQs:
- Ubuntu / Debian Linux: Install Monit Linux Server Monitoring Utility
- View Installation / Uninstallation Script Inside The RPM File
- Restrict certain users log onto a system via SSH server
- HP-UX start or stop / restart OpenSSH SSHD service
- Monit: Monitor BIND 9 (named) Name Server and Auto Restart SSH If It Does Not Respond
Leave a Reply
We encourage your comments, and suggestions. But please stay on topic, be polite, and avoid spam. Thank you very much for stopping by our site!
Tags: /etc/init.d/monit, /etc/monit/monitrc, auto restart ssh, linux monitor tool, linux monitor tools, log messages, monitor ssh, monitoring services, port 22, server monitoring, server system, sshd daemon, Ubuntu Linux



Recent Comments
Today ~ 2 Comments
Today ~ 7 Comments
Today ~ 3 Comments
Today ~ 2 Comments
Today ~ 2 Comments