Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I like to know where the log files that store the SSH logins are located, the last login IP is shown when logged in via SSH so I'm sure they are kept somewhere, can anyone shed som light on this?

System: Ubuntu 12.04.4 LTS


share|improve this question
up vote 1 down vote accepted

You can use the last command to view login logs:

last -d

Will, to quote the manual page:

For non-local logins, Linux stores not only the host name of the remote host but its IP number as well. This option translates the IP number back into a hostname.

There is also:

last -i

This option is like -d in that it displays the IP number of the remote host, but it displays the IP number in numbers-and-dots notation.

for more information run man last to view the manual page.

You can also use lastb, which will display only the bad login attempts:

sudo lastb

last reads from:


lastb reads from:


You can also view the last successful login of a user with this:

lastlog -u USERNAME

which, if it is a ssh login, will display something like:

Last login: Thur Jan 02 09:52:12 2014 from
share|improve this answer
Perfect, all I needed. – user2028213 Jan 20 '14 at 11:20

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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