LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Security
User Name
Password
Linux - Security This forum is for all security related questions.
Questions, tips, system compromises, firewalls, etc. are all included here.

Notices


Reply
  Search this Thread
Old 10-14-2008, 01:43 PM   #1
linuxfia
Member
 
Registered: Apr 2008
Distribution: ubuntu 7.10, centos 4 & 5
Posts: 84

Rep: Reputation: 15
Questions about last command output


hello

When I do a last grep on user jdoe, I get:
jdoe pts/1 localhost Mon Aug 2 10:20 - 10:20 (00:00)
jdoe sshd localhost Mon Aug 2 10:20 - 10:20 (00:00)
jdoe pts/6 67.16.1.10.trm0 Mon Aug 2 10:14 - 10:20 (00:05)
jdoe sshd 67.16.1.10.trm0 Mon Aug 2 10:14 - 10:20 (00:05)


It seems the bottom 2 lines show the IP address where the connection was made from.

The top 2 lines says "localhost". What does that mean? It's not saying it logged on locally to the console right?
 
Old 10-14-2008, 01:47 PM   #2
indienick
Senior Member
 
Registered: Dec 2005
Location: London, ON, Canada
Distribution: Arch, Ubuntu, Slackware, OpenBSD, FreeBSD
Posts: 1,853

Rep: Reputation: 65
It most certainly is saying that the user, "jdoe", had logged on locally.
 
Old 10-14-2008, 04:38 PM   #3
linuxfia
Member
 
Registered: Apr 2008
Distribution: ubuntu 7.10, centos 4 & 5
Posts: 84

Original Poster
Rep: Reputation: 15
It doesn't mean the user logged on from the physical console right?
Would ssh'ing into the server remotely produce the same log?

This is the other part of the log:

Accepted keyboard-interactive for jdoe from 67.16.1.10 port 50752 ssh2
messages.005:Aug 2 10:20:20 server.domain.com sshd[29202]: [ID 900126 auth.info] Accepted keyboard-interactive for jdoe from 127.0.0.1 port 57521 ssh2
 
Old 10-14-2008, 09:10 PM   #4
indienick
Senior Member
 
Registered: Dec 2005
Location: London, ON, Canada
Distribution: Arch, Ubuntu, Slackware, OpenBSD, FreeBSD
Posts: 1,853

Rep: Reputation: 65
To be honest, I do not know.
 
Old 10-14-2008, 09:32 PM   #5
gilead
Senior Member
 
Registered: Dec 2005
Location: Brisbane, Australia
Distribution: Slackware64 14.0
Posts: 4,141

Rep: Reputation: 168Reputation: 168
When I log in locally to my boxes (Slackware) I get tty1 (or whatever tty it was) and the host field is empty. If I use last -a -d I get 0.0.0.0 for the host.

The only time I see values like 127.0.0.1 for the connecting host when I'm not actually locally signing in is when I use NX over an SSH tunnel. In that case, I get an entry for last showing my remote IP addres as I'd expect, but in /var/log/messages I get something like this:
Code:
Oct 13 08:36:36 zaphod sshd[24561]: Accepted publickey for nx from 127.0.0.1 port 42308 ssh2
Were you running any programs over an SSH tunnel when those entries occurred?
 
Old 10-15-2008, 11:28 AM   #6
linuxfia
Member
 
Registered: Apr 2008
Distribution: ubuntu 7.10, centos 4 & 5
Posts: 84

Original Poster
Rep: Reputation: 15
I'm not sure since that wasn't me but another user...
When I do last, other users don't have an entry of localhost but only that particular user does.
When you do NX over ssh, does it log as "localhost" when using last command and in var/log/messages as 127.0.0.1?
 
Old 10-15-2008, 08:01 PM   #7
gilead
Senior Member
 
Registered: Dec 2005
Location: Brisbane, Australia
Distribution: Slackware64 14.0
Posts: 4,141

Rep: Reputation: 168Reputation: 168
I went back and matched up time stamps from remotely connecting via SSH and using NX with the output from last. There are no localhost messages as you describe. I also haven't been able to force a hostname of localhost by connecting locally.

It could be differences in the versions of utilities between Ubuntu and Slackware unless someone else has jdoe's credentials and may have used them locally. That doesn't seem likely given that the timestamps follow on from each other.
 
Old 10-17-2008, 04:33 PM   #8
linuxfia
Member
 
Registered: Apr 2008
Distribution: ubuntu 7.10, centos 4 & 5
Posts: 84

Original Poster
Rep: Reputation: 15
Ok, thanks for your help!
 
Old 10-23-2008, 06:35 PM   #9
linuxfia
Member
 
Registered: Apr 2008
Distribution: ubuntu 7.10, centos 4 & 5
Posts: 84

Original Poster
Rep: Reputation: 15
So how do I delete the lastlog?
 
Old 10-23-2008, 10:37 PM   #10
gilead
Senior Member
 
Registered: Dec 2005
Location: Brisbane, Australia
Distribution: Slackware64 14.0
Posts: 4,141

Rep: Reputation: 168Reputation: 168
Do you mean truncate it or remove it entirely? To truncate it, you can use the following - I'd use lsof first to see if anything is using the file:
Code:
lsof /var/log/lastlog
:>/var/log/lastlog
 
Old 10-24-2008, 11:16 AM   #11
linuxfia
Member
 
Registered: Apr 2008
Distribution: ubuntu 7.10, centos 4 & 5
Posts: 84

Original Poster
Rep: Reputation: 15
I meant to clear all of it so when I run "last", nothing shows up.
Thanks.
 
Old 10-30-2008, 12:03 PM   #12
linuxfia
Member
 
Registered: Apr 2008
Distribution: ubuntu 7.10, centos 4 & 5
Posts: 84

Original Poster
Rep: Reputation: 15
Anyone know the command to to clear all of it so when I run the "last" command, nothing shows up?
 
Old 10-30-2008, 01:20 PM   #13
gilead
Senior Member
 
Registered: Dec 2005
Location: Brisbane, Australia
Distribution: Slackware64 14.0
Posts: 4,141

Rep: Reputation: 168Reputation: 168
Sorry, I listed the wrong filename before. last uses /var/log/wtmp, so to truncate it:
Code:
:>/var/log/wtmp
You should also be able to move it to another file (e.g. /var/log/wtmp.1 like logrotate does) and create a new, empty file with touch.

Last edited by gilead; 10-30-2008 at 01:21 PM.
 
Old 10-31-2008, 02:53 PM   #14
linuxfia
Member
 
Registered: Apr 2008
Distribution: ubuntu 7.10, centos 4 & 5
Posts: 84

Original Poster
Rep: Reputation: 15
Cool, thanks!
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
How to redirect the output of exec command output in perl? sudhap85 Linux - Newbie 3 08-28-2009 03:35 PM
how to get the absolute path information of a command from ps command output ratul_11 Linux - General 1 08-06-2008 02:10 AM
How do I parse the output of a command that output to standard out? gauol Programming 9 01-17-2008 01:54 PM
Questions about ls output hadyy Linux - General 9 12-26-2007 08:01 AM
Redirecting output to a command-line argument of another command madiyaan Linux - Newbie 1 02-19-2005 04:35 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Security

All times are GMT -5. The time now is 06:54 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration