SnapOverflow

SnapOverflow Logo SnapOverflow Logo

SnapOverflow Navigation

  • Home
  • Server
  • Ubuntu

Mobile menu

Close
  • Home
  • System Administrators
    • Hot Questions
    • New Questions
    • Tags
  • Ubuntu
    • Hot Questions
    • New Questions
    • Tags
  • Help
Home / server / Questions / 130482
Accepted
grigoryvp
grigoryvp
Asked: 2010-04-09 02:22:10 +0800 CST2010-04-09 02:22:10 +0800 CST 2010-04-09 02:22:10 +0800 CST

How to check sshd log?

  • 772

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?

ssh
  • 8 8 Answers
  • 850173 Views

8 Answers

  • Voted
  1. Ram
    2013-02-20T11:56:51+08:002013-02-20T11:56:51+08:00

    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'
    
    • 224
  2. Ciro Santilli OurBigBook.com
    2017-08-13T23:13:50+08:002017-08-13T23:13:50+08:00

    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

    • 40
  3. RedEyed
    2021-02-24T04:43:59+08:002021-02-24T04:43:59+08:00

    The modern way to view logs:

    1. All messages about sshd:
      journalctl -t sshd
      or
      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

    • 34
  4. Best Answer
    Peto
    2010-04-09T03:37:58+08:002010-04-09T03:37:58+08:00

    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
    • 11
  5. guest
    2017-06-29T06:24:14+08:002017-06-29T06:24:14+08:00

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

    grep -rsh sshd /var/log |sort
    
    • 7
  6. Aditya Mittal
    2017-11-10T16:44:47+08:002017-11-10T16:44:47+08:00

    You can use the following command to see the logs from SSH:

    tail -f /var/log/auth.log
    
    • 4
  7. Mêlis Farothserkê
    2022-06-16T08:37:56+08:002022-06-16T08:37:56+08:00

    Not for topicstarter, but for another opensuse tumbleweed users:

    systemctl status sshd.service
    journalctl -xeu sshd.service
    

    The first gives you the status and time of fault:

     sshd.service - OpenSSH Daemon
         Loaded: loaded (/usr/lib/systemd/system/sshd.service; enabled; vendor preset: disabled)
         Active: failed (Result: exit-code) since Wed 2022-06-15 19:15:20 MSK; 10min ago
    

    The second may give you more details, something like:

    Jun 15 19:15:19 localhost.localdomain sshd[2124]: 
    /etc/ssh/sshd_config.d/sshd.conf line 121: Directive 'usepam' is not allowed within a Match block
    
    • 0
  8. tri.akki7
    2021-07-09T23:44:59+08:002021-07-09T23:44:59+08:00

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

    $ tail /var/log/audit/audit.log
    
    • -2

Sidebar

Stats

  • Questions 681965
  • Answers 980273
  • Best Answers 280204
  • Users 287326
  • Popular
  • Answers
  • Marko Smith

    Ping a Specific Port

    • 18 Answers
  • Marko Smith

    How do I tell Git for Windows where to find my private RSA key?

    • 30 Answers
  • Marko Smith

    How do you restart php-fpm?

    • 18 Answers
  • Marko Smith

    What's the default superuser username/password for postgres after a new install?

    • 5 Answers
  • Marko Smith

    What port does SFTP use?

    • 6 Answers
  • Marko Smith

    Resolve host name from IP address

    • 8 Answers
  • Marko Smith

    How can I sort du -h output by size

    • 30 Answers
  • Marko Smith

    Command line to list users in a Windows Active Directory group?

    • 9 Answers
  • Marko Smith

    What is a Pem file and how does it differ from other OpenSSL Generated Key File Formats?

    • 3 Answers
  • Marko Smith

    How to determine if a bash variable is empty?

    • 15 Answers
  • Martin Hope
    Davie Ping a Specific Port 2009-10-09 01:57:50 +0800 CST
  • Martin Hope
    binaryorganic How do I tell Git for Windows where to find my private RSA key? 2010-10-26 08:45:39 +0800 CST
  • Martin Hope
    tobym What exactly do the colors in htop status bars mean? 2010-09-14 12:22:43 +0800 CST
  • Martin Hope
    MikeN In Nginx, how can I rewrite all http requests to https while maintaining sub-domain? 2009-09-22 06:04:43 +0800 CST
  • Martin Hope
    Tom Feiner How can I sort du -h output by size 2009-02-26 05:42:42 +0800 CST
  • Martin Hope
    0x89 What is the difference between double and single square brackets in bash? 2009-08-10 13:11:51 +0800 CST
  • Martin Hope
    Kyle Brandt How does IPv4 Subnetting Work? 2009-08-05 06:05:31 +0800 CST
  • Martin Hope
    Noah Goodrich What is a Pem file and how does it differ from other OpenSSL Generated Key File Formats? 2009-05-19 18:24:42 +0800 CST
  • Martin Hope
    Brent How to determine if a bash variable is empty? 2009-05-13 09:54:48 +0800 CST
  • Martin Hope
    cletus How do you find what process is holding a file open in Windows? 2009-05-01 16:47:16 +0800 CST

Related Questions

Trending Tags

linux nginx windows networking ubuntu domain-name-system amazon-web-services active-directory apache-2.4 ssh

Explore

  • Home
  • Questions
    • Hot Questions
    • New Questions
  • Tags
  • Help

Footer

SnapOverflow

About Us

  • About Us
  • Contact Us

Legal Stuff

  • Privacy Policy

Help

© 2022 SOF-TR. All Rights Reserve