I have Ubuntu 9.10 installed with sshd and I can successfully connect to it using login and password. I have configured an RSA key login and now have "Server refused our key" as expected. Ok, now I want to check sshd log in order to figure out a problem. I have examined /etc/ssh/sshd_config and it have

SyslogFacility AUTH
LogLevel INFO

Ok. I'm looking at /var/log/auth.log and... it's empty O_O. Changing Loglevel to VERBOSE helps nothing - auth.log is still empty. Any hints how I can check sshd log?

  • 8
    Did you check your syslog configuration? I don't run Ubuntu, but it may redirect the AUTH facility to a different logfile. Maybe /var/log/messages ? Apr 8 '10 at 10:23
  • How to check a syslog configuration? Unfortunately, i'm not very good a linux :(. cat /var/log/messages | grep ssh shows nothing :(.
    – grigoryvp
    Apr 8 '10 at 10:28
  • You are correct. /etc/syslog.conf redirects AUTH to /var/logauth.log. Please write your answer so i can accept it :)
    – grigoryvp
    Apr 8 '10 at 10:31
  • 4
    On my servers, sshd logs to /var/log/secure. This is configured in /etc/rsyslog.conf, on the line beginning "authpriv.*" Jun 20 '13 at 14:34
  • 1
    authpriv?? How the heck were we supposed to know that had anything to do with sshd? :-) May 31 '15 at 12:54

If no one else is using the system at the moment you could do what i've done in such cases:

  • stop sshd service (at least i've been able to do this while logged in via ssh)
  • start sshd manually and add some -d options to get more verbose debug output. Unless you have something funky going on it should use the same keys and config it does when started properly
  • 175
    Stopping SSHD on a remote server is a really bad idea. This may solve the problem for some (or most) setups most of the time, but if ANYTHING goes wrong - your connection, power on either end, forgetfulness, etc - you're locked out of the box. Which is bad news.
    – Sudowned
    Nov 21 '12 at 18:58
  • 1
    Well, it should be noted that the only way you could start the service after manually stopping it would be to have some other kind of access to it, like another non-SSH remote connection, or you're sitting in front of it. Apr 23 '15 at 16:32
  • 44
    How does this answer the question? I landed here from a web search expecting to learn how to check the SSHD log files, not what worked for you for some problem... Damn I wish readers on the Stack Exchange network would actually read and answer the question at hand, and not the question they want it to be....
    – user145545
    Aug 23 '15 at 16:00
  • 5
    You can start another sshd on another port. Connect to that one. Then stop the main sshd and start a new one on port 22. If anything fails, reboot the box using your DRAC or cloud management. You should have sshd starting on boot right? No worries. Feb 17 '17 at 14:43
  • 2
    @JoelESalas The community doesn't decide which answers are accepted.
    – kasperd
    Feb 4 '18 at 13:10

Creating an answer based on the comments above, credit to @Prof. Moriarty and @Eye of Hell

SSH auth failures are logged here /var/log/auth.log

The following should give you only ssh related log lines

grep 'sshd' /var/log/auth.log

To be on the safe side, get the last few hundred lines and then search (because if the log file is too large, grep on the whole file would consume more system resources, not to mention will take longer to run)

View sshd entries in the last 500 lines of the log:

tail -n 500 /var/log/auth.log | grep 'sshd'

or to follow the log output as you test:

tail -f -n 500 /var/log/auth.log | grep 'sshd'

  • 11
    This answer. Other answer with green arrow is bogus. Change arrow.
    – user54883
    Aug 4 '14 at 23:58
  • 7
    Why not use tail -f ... to monitor it in real time? Would this be an issue with larger log files?
    – ingh.am
    Feb 2 '15 at 12:12
  • 8
    less +F ... will 'tail' in real time, and it's much more powerful than tail
    – northben
    May 7 '15 at 15:45
  • 5
    And lnav is even better than less/tail Jan 13 '16 at 18:17
  • 18
    P.s.: if your server is a Red Hat (as CentOS), the path of sshd/login records log is /var/log/secure (check /var/log folder for the log files of specific dates too). See this answer: serverfault.com/questions/465833/… Jan 5 '18 at 16:25

If you can try the failing connection again easily, one way easy way is to start an SSH server on a free port such as 2222:

/usr/sbin/sshd -d -p 2222

and then retry the connection with:

ssh -p 2222 user@host

By using the different port -p 2222, we don't have to stop the main SSH server, which could lock us out.

See also: https://unix.stackexchange.com/a/55481/32558

  • 5
    One of the best options, specially if you only have SSH access to a server. Debugging the connection by stopping the ssh server will drop you out of session. Just start a new ssh daemon on a different port and test the login using that port. Oct 15 '19 at 19:38
  • 2
    @AttilaAntal Small correction: stopping sshd will not kill active ssh sessions. This method is a good precaution in case something goes wrong, but in theory you can easily stop and then restart sshd over ssh. Feb 9 '20 at 3:35
  • 1
    @ParkerKemp it doesn't kill the connection, and if everything is working as expected, you should be able to continue using it after after restarting the daemon. The problem, however, will be if for some reason the Daemon couldn't start. Then the active session will drop. Feb 10 '20 at 15:35

The modern way to see logs

  1. All messages about sshd:
    journalctl -t sshd
    journalctl -u ssh where -u == unit

  2. Messages about sshd from the last boot:
    journalctl -t sshd -b0

  3. Messages about sshd from the last boot in the reverse order:
    journalctl -t sshd -b0 -r

  • 2
    Yep !!! Also journalctl -u ssh, where u = unit . With this syntax you can use for any systemd unit
    – MarcoZen
    Apr 19 '21 at 19:08
  • I tried -u sshd and it didn't work, but -u ssh works, thanks!
    – RedEyed
    Apr 21 '21 at 12:23

If you want to see all log messages about sshd, run this:

grep -rsh sshd /var/log |sort
  • 2
    Logs will start with entries like Mar 14 19:52:04 which exclude the year and are not easily sorted (though you may get lucky with sort --month-sort assuming you don't go over a boundary between years). The log files themselves are already sorted, so you just have to scan them in the right order. Also, the recursive grep -r call will be really slow on systems with large logs. There's no reason to additionally scan things like your HTTPD logs.
    – Adam Katz
    Aug 14 '17 at 17:27
  • thx, i didn't know what flavor i was on, but this helped me find /var/log/secure (i actually ended up changing the command to grep -Rsl sshd /var/log but +1 for getting my thinking cap to appear).
    – WEBjuju
    Dec 4 '19 at 0:01
  • 1
    tail -5000f /var/log/messages|grep -i sshd Feb 16 '20 at 18:26

You can tail -f /var/log/auth.log

  • 1
    Welcome to ServerFault. Did you read the question? He isn't getting data in that file. tailing it useless if it doesn't have any data in it.
    – chicks
    Nov 10 '17 at 1:56
  • @chicks That's funny. Answer with most votes is almost the same like this..
    – Qback
    Feb 9 '18 at 7:27

In CentOS 7. I have found out SSH logs over here:

$ tail /var/log/audit/audit.log

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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