Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
last login not working as expected [solved]
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Portage & Programming
View previous topic :: View next topic  
Author Message
Majed17
Guru
Guru


Joined: 31 Aug 2011
Posts: 333
Location: Minsk, Belarus

PostPosted: Wed Jun 27, 2018 2:24 pm    Post subject: last login not working as expected [solved] Reply with quote

Peace,
I've been using other linux distributions and I found it handy to see when is the last log in.
so in
/etc/ssh/sshd_config
I have modified:
Code:
#PrintMotd yes
#PrintLastLog yes

but :
Code:
date
Wed Jun 27 17:17:22 +03 2018

then relogging gives:
Code:
Last login: Wed Jun 27 17:18:32 2018 from 192.168.10.10

lastlog
shows the same.
The configuration is identical with an opensuse distribution, in regards to sshd except in /etc/pam.d/sshd there are different entires.
I tried emptying last log and wtmp but that didn't help.
So what is the correct configuration to display the correct last ?
_________________
Seek and you shall find, Knock and it shall be opened, cry and you shall find comfort.


Last edited by Majed17 on Thu Jun 28, 2018 6:45 am; edited 1 time in total
Back to top
View user's profile Send private message
guitou
Guru
Guru


Joined: 02 Oct 2003
Posts: 534
Location: France

PostPosted: Wed Jun 27, 2018 2:27 pm    Post subject: Reply with quote

Hello.
If you leave the heading #, this means line is commented out ;)

++
Gi)
Back to top
View user's profile Send private message
Majed17
Guru
Guru


Joined: 31 Aug 2011
Posts: 333
Location: Minsk, Belarus

PostPosted: Wed Jun 27, 2018 2:44 pm    Post subject: Reply with quote

Well before that I tried without a comment and nothing changed!
the sense was to copy the open suse configuration. anything else?
_________________
Seek and you shall find, Knock and it shall be opened, cry and you shall find comfort.
Back to top
View user's profile Send private message
bunder
Bodhisattva
Bodhisattva


Joined: 10 Apr 2004
Posts: 5939

PostPosted: Wed Jun 27, 2018 2:45 pm    Post subject: Reply with quote

Both those settings default to yes, to turn them off you have to explicitly set them to no.
_________________
Neddyseagoon wrote:
The problem with leaving is that you can only do it once and it reduces your influence.

banned from #gentoo since sept 2017
Back to top
View user's profile Send private message
guitou
Guru
Guru


Joined: 02 Oct 2003
Posts: 534
Location: France

PostPosted: Wed Jun 27, 2018 2:49 pm    Post subject: Reply with quote

Well, did you restart the service after your changes?
Back to top
View user's profile Send private message
khayyam
Watchman
Watchman


Joined: 07 Jun 2012
Posts: 6227
Location: Room 101

PostPosted: Wed Jun 27, 2018 2:51 pm    Post subject: Reply with quote

Majed17 ...

to elaborate on guitou's comment:

Code:
# grep -i print /etc/ssh/sshd_config
PrintMotd no
PrintLastLog no

Also ...

man login wrote:
You may turn off the printing of the system message file, /etc/motd, by creating a zero-length file .hushlogin in your login directory

... and:

man login wrote:
The following configuration variables in /etc/login.defs change the behavior of this tool:
[...]
LASTLOG_ENAB (boolean)
Enable logging and display of /var/log/lastlog login time info.

HTH & best ... khay
Back to top
View user's profile Send private message
Majed17
Guru
Guru


Joined: 31 Aug 2011
Posts: 333
Location: Minsk, Belarus

PostPosted: Wed Jun 27, 2018 2:53 pm    Post subject: Reply with quote

For God's sake, you really assume you are smartest one living?
and for your information, both of these setting are no to begin with, which frankly is unwise. I think pam.d needs to be modified!
_________________
Seek and you shall find, Knock and it shall be opened, cry and you shall find comfort.
Back to top
View user's profile Send private message
khayyam
Watchman
Watchman


Joined: 07 Jun 2012
Posts: 6227
Location: Room 101

PostPosted: Wed Jun 27, 2018 3:03 pm    Post subject: Reply with quote

Majed17 wrote:
For God's sake, you really assume you are smartest one living? and for your information, both of these setting are no to begin with, which frankly is unwise. I think pam.d needs to be modified!

Majed17 ... you're speaking to me?

Code:
% ssh localhost
%

... so notice, no motd and no lastlog!

best ... khay
Back to top
View user's profile Send private message
Majed17
Guru
Guru


Joined: 31 Aug 2011
Posts: 333
Location: Minsk, Belarus

PostPosted: Wed Jun 27, 2018 4:59 pm    Post subject: Reply with quote

you didn't get me,
Code:
ssh localhost
Password:
Last login: Wed Jun 27 19:54:39 2018 from ::1

what I want is not the current log in but the one before like it must do!
and it doesn't matter whether there is a # before the command or not, it still takes it!
_________________
Seek and you shall find, Knock and it shall be opened, cry and you shall find comfort.
Back to top
View user's profile Send private message
khayyam
Watchman
Watchman


Joined: 07 Jun 2012
Posts: 6227
Location: Room 101

PostPosted: Wed Jun 27, 2018 6:08 pm    Post subject: Reply with quote

Majed17 wrote:
you didn't get me, [...] what I want is not the current log in but the one before like it must do!

Majed17 ... I see, yes, my bad, I must have read your initial post too quickly, and absorbed the direction taken subsequently. Anyhow, yes, you get this because of pam.d/system-login, if you want "the one before" then basically what you need to do is have sshd do the lastlog, and inform pam not to (by commenting the line):

/etc/ssh/sshd_config:
PrintLastLog yes

/etc/pam.d/system-login:
#session        optional    pam_lastlog.so silent

You'll then get that behavior:

Code:
% date
Wed Jun 27 19:55:47 CEST 2018
% lastlog -u khayyam
Username         Port     From             Latest
khayyam          pts/8    127.0.0.1        Wed Jun 27 19:55:13 +0200 2018
% ssh localhost
Last login: Wed Jun 27 19:55:13 2018 from 127.0.0.1

edit: you might also get that same behavior with 'PrintLastLog yes' and net-misc/openssh built with USE="-pam" (untested).

Sorry for the confusion & best ... khay
Back to top
View user's profile Send private message
Majed17
Guru
Guru


Joined: 31 Aug 2011
Posts: 333
Location: Minsk, Belarus

PostPosted: Thu Jun 28, 2018 6:44 am    Post subject: Reply with quote

Your a life savior, especially from internal spies.
I'm sorry for the confusion, I shouldn't have replied until some time after when everyone has written what they wanted!
Here is the million dollar question, why isn't this the default behavior like in all the other linux distributions I have installed except Kali?
_________________
Seek and you shall find, Knock and it shall be opened, cry and you shall find comfort.
Back to top
View user's profile Send private message
khayyam
Watchman
Watchman


Joined: 07 Jun 2012
Posts: 6227
Location: Room 101

PostPosted: Thu Jun 28, 2018 9:55 am    Post subject: Reply with quote

Majed17 wrote:
Your a life savior, especially from internal spies. I'm sorry for the confusion, I shouldn't have replied until some time after when everyone has written what they wanted!

Majed17 ... no problem, the fault is entirely mine.

Majed17 wrote:
Here is the million dollar question, why isn't this the default behavior like in all the other linux distributions I have installed except Kali?

I'm not sure, I think it might be a bug rather than a feature, it's pointless to provide the current login as 'lastlog', because that information is known for obvious reasons. There is another topic where lastlog is misbehaving, and I suspect that these issues are related.

best ... khay
Back to top
View user's profile Send private message
Majed17
Guru
Guru


Joined: 31 Aug 2011
Posts: 333
Location: Minsk, Belarus

PostPosted: Thu Jun 28, 2018 10:39 am    Post subject: Reply with quote

Yeah that topic is where I figured out the issue is pam related.
and
Quote:
the fault is entirely mine

that's flattery.
_________________
Seek and you shall find, Knock and it shall be opened, cry and you shall find comfort.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Portage & Programming All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum