As we know SSH protocol provide remote login facility and hence it is important to maintain the login logs. System admin can achieve this by configuring in syslogd services.
In linux, syslogd is the unix logging service which maintains the logs that are sent by the programmes to the syslog daemon, syslogd and forwards them to another destination such as a console or a file. Destination is specified in the syslog configuration file /etc/syslog.conf.
1) Enable syslog Logging
[[email protected] ~]# cat /etc/syslog.conf | grep -i ssh
By default, ssh logging is enabled, if not enable then enable SSH logging we need to configure the syslog.conf by adding in /etc/syslog.conf file.
When SSH server runs, it will produce the log messages in sshd.log to describe what is going on. These log messages will help the system administrator to track the system details such as who logged in and logged out and to trouble shoot the problem.
/etc/ssh/sshd_config file is a system wide configuration file for open SSH service which allows you to set options that modifies the operation of the daemon. This configuration file contains keyword-value pairs and one per line with keywords being case sensitive.
SyslogFacility AUTH and AUTHPRIV
Messages received by syslogd are processed according to their facility which indicates a the origin of the message. Standard SyslogFacility includes KERN (Messages from the OS Kernel), DAEMON (Messages from the Service or Daemon), USER (Messages from the user processes), MAIL (Messages from the email System) and others.
By default, the facility for SSH server messages is AUTHPRIV. This choice may be changed with the SSH keyword SyslogFacility which determines the syslog facility code for logging SSH Messages. Other possible values of SyslogFacility are DAEMON, USER, AUTH, AUTHPRIV, LOCAL0, LOCAL1, LOCAL2, LOCAL3, LOCAL4, LOCAL5, LOCAL6 and LOCAL7. The default is AUTHPRIV.
The option SyslogFacility specifies the facility code used when logging messages from sshd. The facility specifies the subsystem that produced the message--in our case, AUTH.
Normally, all authentication related messages are logged with the AUTHPRIV (or AUTH) facility [intended to be secure and never seen by unwanted eyes], while normal operational messages are logged with the DAEMON facility.
2) Enable Auth in sshd_config file
[[email protected] ssh]# cat sshd_config | grep -i SyslogFacility
It gives the verbosity level that is used when logging messages from sshd. The possible other values are QUIET, FATAL, ERROR, INFO, VERBOSE, DEBUG, DEBUG1, DEBUG2 and DEBUG3. The default is INFO. DEBUG and DEBUG1 are equivalent. DEBUG2 and DEBUG3 each specify higher levels of debugging the out-put.
If you want to record more information such as failed login attempts, then you should increase the logging level to VERBOSE.
Make sure to uncomment below lines to enable loglevel.
[[email protected] ssh]# cat sshd_config | grep -i LogLevel
[[email protected] ssh]#
3) Restart ssh service
To enable the service of SSH, use the service sshd start command.
[[email protected] ~]# service sshd start
Starting sshd: [ OK ]
You can use watch command to see live ssh log file updates.
[[email protected] ~]#watch /var/log/messages
Thanks for reading this article and let me know your comments.