31

Trying to find out why fail2ban is not working.

Where does Ubuntu 14.04 log SSH access attempts?

1
  • You could ask rsyslogd which files it logs to: cat /etc/rsyslog.d/* | egrep -v '^#|^$' | egrep -o '/[^ ]+' on your system.
    – waltinator
    Jun 25, 2015 at 19:04

2 Answers 2

38

All login attempts are logged to /var/log/auth.log

Search for brute-force SSH logins

Run this command:

grep sshd.\*Failed /var/log/auth.log | less

Search for failed connections

Run this command:

grep sshd.*Did /var/log/auth.log | less

UPDATE:

You should try restarting the syslog daemon to see if it starts to log to the correct file.

sudo service rsyslog restart

Once you have messages going to the auth.log it should start working.

6
  • 1
    I looked in /var/log/auth.log and the file is empty and nothing is being logged to it...
    – timbram
    Jun 25, 2015 at 16:00
  • check the update
    – Maythux
    Jun 25, 2015 at 16:03
  • Ok, just restarted rsyslog. Then logged out, tried to log in with a few wrong passwords. Then went ahead and logged in properly. Still nothing logged to auth.log.
    – timbram
    Jun 25, 2015 at 16:09
  • What do you think I should look at next?
    – timbram
    Jun 25, 2015 at 16:10
  • I noticed that in /var/log the username that I use (my non-root user) is the owner of a lot of these files. Could that be the problem do you think?
    – timbram
    Jun 25, 2015 at 16:12
2

The default log settings for ssh are "INFO".

If you want to have it include login attempts in the log file, you'll need to edit the /etc/ssh/sshd_config file and change the "LogLevel" from INFO to VERBOSE.

After that, restart the sshd daemon with

sudo service rsyslog restart

After that, the ssh login attempts will be logged into the /var/log/auth.log file.

2
  • Thanks for the formatting clarifications. I'll look for how to do that next time I put in an answer. Dec 20, 2016 at 19:40
  • sudo systemctl restart rsyslog.service for newer versions of Ubuntu.
    – Indika K
    Oct 5, 2021 at 9:48

Not the answer you're looking for? Browse other questions tagged or ask your own question.