I realize this is perhaps nothing to worry about, but I do like the idea of being able to see that the last user logged in was from a known IP. Plus I like a mystery..
I am not interested in all the alternative ways that could simulate this feature.
I've tried to cover all the details below. If anyone can offer suggestions I'd love to look into it and see if this can be figured out.
Issue:
CentOS 6 on a KVM
CentOS 6 on a OpenVZ
Evidence:
1. Found potential 'lastlog' related errors in log
2. lastb: /var/log/btmp: No such file or directory
Steps Taken:
- compared sshd_config between systems and they're virtually the same
- created /etc/log/lastlog
- created /etc/log/btmp
touch btmp
chmod 600 btmp (to match VZ permissions)
chown root.utmp btmp (to match VZ owner.group)
touch /var/log/lastlog
chmod 644 lastlog (to match VZ permissions)
chown root.root lastlog (to match VZ owner.group)
no effect and files were not growing beyond 0 size
..btmp is for failed logins and since SSH is not 22 I guess it's possible no
ouside attempts being made. Can try making log errors myself or set back to 22.
- installed finger
lastlog grew buy running finger, however "Last login:" not being displayed after SSH login
- edit /etc/ssh/sshd_config
PrintLastLog Yes (uncomment setting & ensure set to yes)
- restart sshd
system sshd restart
Currently active /etc/ssh/sshd_config KVM ("Last login:" display not working)
Currently active /etc/ssh/sshd_config OpenVZ ("Last login:" displays properly)
Result: no "Last login:" display after successful SSH login
I am not interested in all the alternative ways that could simulate this feature.
I've tried to cover all the details below. If anyone can offer suggestions I'd love to look into it and see if this can be figured out.
Issue:
CentOS 6 on a KVM
Code:
********************************************************************************
Authenticating with public key "root@srv2.." from agent
[root@srv2 ~]#
Code:
********************************************************************************
Authenticating with public key "admin@srv1.." from agent
Last login: Mon Mar 24 02:17:27 2014 from ..comcartel.net
[admin@srv1 ~]$
1. Found potential 'lastlog' related errors in log
Code:
Mar 23 11:37:37 srv2 sshd[1416]: lastlog_openseek: Couldn't stat /var/log/lastlog: No such file or directory
Mar 23 11:37:58 srv2 sshd[1413]: pam_unix(sshd:session): session closed for user root
Mar 23 23:35:51 srv2 sshd[1586]: Accepted publickey for root from me.me.me.16 port 15009 ssh2
Mar 23 23:35:51 srv2 sshd[1586]: pam_unix(sshd:session): session opened for user root by (uid=0)
Mar 23 23:35:51 srv2 sshd[1590]: lastlog_openseek: Couldn't stat /var/log/lastlog: No such file or directory
Mar 23 23:35:51 srv2 sshd[1590]: lastlog_openseek: Couldn't stat /var/log/lastlog: No such file or directory
Mar 24 00:16:13 srv2 sshd[1586]: pam_unix(sshd:session): session closed for user root
Mar 24 02:13:50 srv2 sshd[1860]: Accepted publickey for root from me.me.me.16 port 15257 ssh2
Mar 24 02:13:50 srv2 sshd[1860]: pam_unix(sshd:session): session opened for user root by (uid=0)
Mar 24 02:13:50 srv2 sshd[1863]: lastlog_openseek: Couldn't stat /var/log/lastlog: No such file or directory
Mar 24 02:13:50 srv2 sshd[1863]: lastlog_openseek: Couldn't stat /var/log/lastlog: No such file or directory
Steps Taken:
- compared sshd_config between systems and they're virtually the same
- created /etc/log/lastlog
- created /etc/log/btmp
touch btmp
chmod 600 btmp (to match VZ permissions)
chown root.utmp btmp (to match VZ owner.group)
touch /var/log/lastlog
chmod 644 lastlog (to match VZ permissions)
chown root.root lastlog (to match VZ owner.group)
no effect and files were not growing beyond 0 size
..btmp is for failed logins and since SSH is not 22 I guess it's possible no
ouside attempts being made. Can try making log errors myself or set back to 22.
- installed finger
lastlog grew buy running finger, however "Last login:" not being displayed after SSH login
- edit /etc/ssh/sshd_config
PrintLastLog Yes (uncomment setting & ensure set to yes)
- restart sshd
system sshd restart
Currently active /etc/ssh/sshd_config KVM ("Last login:" display not working)
Code:
# $OpenBSD: sshd_config,v 1.80 2008/07/02 02:24:18 djm Exp $
# This is the sshd server system-wide configuration file. See
# sshd_config(5) for more information.
# This sshd was compiled with PATH=/usr/local/bin:/bin:/usr/bin
# The strategy used for options in the default sshd_config shipped with
# OpenSSH is to specify options with their default value where
# possible, but leave them commented. Uncommented options change a
# default value.
#Port 22
Port 222
#AddressFamily any
#ListenAddress 0.0.0.0
#ListenAddress ::
#ListenAddress <srv2 ip>
# Disable legacy (protocol version 1) support in the server for new
# installations. In future the default will change to require explicit
# activation of protocol 1
Protocol 2
# HostKey for protocol version 1
#HostKey /etc/ssh/ssh_host_key
# HostKeys for protocol version 2
#HostKey /etc/ssh/ssh_host_rsa_key
#HostKey /etc/ssh/ssh_host_dsa_key
# Lifetime and size of ephemeral version 1 server key
#KeyRegenerationInterval 1h
#ServerKeyBits 1024
# Logging
# obsoletes QuietMode and FascistLogging
#SyslogFacility AUTH
SyslogFacility AUTHPRIV
#LogLevel INFO
# Authentication:
#LoginGraceTime 2m
PermitRootLogin yes
#StrictModes yes
#MaxAuthTries 6
#MaxSessions 10
#RSAAuthentication yes
#PubkeyAuthentication yes
#AuthorizedKeysFile .ssh/authorized_keys
#AuthorizedKeysCommand none
#AuthorizedKeysCommandRunAs nobody
# For this to work you will also need host keys in /etc/ssh/ssh_known_hosts
#RhostsRSAAuthentication no
# similar for protocol version 2
#HostbasedAuthentication no
# Change to yes if you don't trust ~/.ssh/known_hosts for
# RhostsRSAAuthentication and HostbasedAuthentication
#IgnoreUserKnownHosts no
# Don't read the user's ~/.rhosts and ~/.shosts files
#IgnoreRhosts yes
# To disable tunneled clear text passwords, change to no here!
#PasswordAuthentication yes
#PermitEmptyPasswords no
PasswordAuthentication yes
# Change to no to disable s/key passwords
#ChallengeResponseAuthentication yes
ChallengeResponseAuthentication no
# Kerberos options
#KerberosAuthentication no
#KerberosOrLocalPasswd yes
#KerberosTicketCleanup yes
#KerberosGetAFSToken no
#KerberosUseKuserok yes
# GSSAPI options
#GSSAPIAuthentication no
GSSAPIAuthentication yes
#GSSAPICleanupCredentials yes
GSSAPICleanupCredentials yes
#GSSAPIStrictAcceptorCheck yes
#GSSAPIKeyExchange no
# Set this to 'yes' to enable PAM authentication, account processing,
# and session processing. If this is enabled, PAM authentication will
# be allowed through the ChallengeResponseAuthentication and
# PasswordAuthentication. Depending on your PAM configuration,
# PAM authentication via ChallengeResponseAuthentication may bypass
# the setting of "PermitRootLogin without-password".
# If you just want the PAM account and session checks to run without
# PAM authentication, then enable this but set PasswordAuthentication
# and ChallengeResponseAuthentication to 'no'.
#UsePAM no
UsePAM yes
# Accept locale-related environment variables
AcceptEnv LANG LC_CTYPE LC_NUMERIC LC_TIME LC_COLLATE LC_MONETARY LC_MESSAGES
AcceptEnv LC_PAPER LC_NAME LC_ADDRESS LC_TELEPHONE LC_MEASUREMENT
AcceptEnv LC_IDENTIFICATION LC_ALL LANGUAGE
AcceptEnv XMODIFIERS
#AllowAgentForwarding yes
#AllowTcpForwarding yes
#GatewayPorts no
#X11Forwarding no
X11Forwarding yes
#X11DisplayOffset 10
#X11UseLocalhost yes
PrintMotd yes
PrintLastLog yes
#TCPKeepAlive yes
#UseLogin no
#UsePrivilegeSeparation yes
#PermitUserEnvironment no
#Compression delayed
#ClientAliveInterval 0
#ClientAliveCountMax 3
#ShowPatchLevel no
#UseDNS yes
#PidFile /var/run/sshd.pid
#MaxStartups 10:30:100
#PermitTunnel no
#ChrootDirectory none
# no default banner path
#Banner none
Banner /etc/ssh.banner.txt
# override default of no subsystems
Subsystem sftp /usr/libexec/openssh/sftp-server
# Example of overriding settings on a per-user basis
#Match User anoncvs
# X11Forwarding no
# AllowTcpForwarding no
# ForceCommand cvs server
AllowUsers root
#AllowUsers admin
Code:
# $OpenBSD: sshd_config,v 1.80 2008/07/02 02:24:18 djm Exp $
# This is the sshd server system-wide configuration file. See
# sshd_config(5) for more information.
# This sshd was compiled with PATH=/usr/local/bin:/bin:/usr/bin
# The strategy used for options in the default sshd_config shipped with
# OpenSSH is to specify options with their default value where
# possible, but leave them commented. Uncommented options change a
# default value.
#Port 22
Port 222
#AddressFamily any
#ListenAddress 0.0.0.0
#ListenAddress ::
#ListenAddress <srv1 ip>
# Disable legacy (protocol version 1) support in the server for new
# installations. In future the default will change to require explicit
# activation of protocol 1
Protocol 2
# HostKey for protocol version 1
#HostKey /etc/ssh/ssh_host_key
# HostKeys for protocol version 2
#HostKey /etc/ssh/ssh_host_rsa_key
#HostKey /etc/ssh/ssh_host_dsa_key
# Lifetime and size of ephemeral version 1 server key
#KeyRegenerationInterval 1h
#ServerKeyBits 1024
# Logging
# obsoletes QuietMode and FascistLogging
#SyslogFacility AUTH
SyslogFacility AUTHPRIV
#LogLevel INFO
# Authentication:
#LoginGraceTime 2m
#PermitRootLogin yes
#StrictModes yes
#MaxAuthTries 6
#MaxSessions 10
#RSAAuthentication yes
#PubkeyAuthentication yes
#AuthorizedKeysFile .ssh/authorized_keys
#AuthorizedKeysCommand none
#AuthorizedKeysCommandRunAs nobody
# For this to work you will also need host keys in /etc/ssh/ssh_known_hosts
#RhostsRSAAuthentication no
# similar for protocol version 2
#HostbasedAuthentication no
# Change to yes if you don't trust ~/.ssh/known_hosts for
# RhostsRSAAuthentication and HostbasedAuthentication
#IgnoreUserKnownHosts no
# Don't read the user's ~/.rhosts and ~/.shosts files
#IgnoreRhosts yes
# To disable tunneled clear text passwords, change to no here!
#PasswordAuthentication yes
#PermitEmptyPasswords no
PasswordAuthentication no
# Change to no to disable s/key passwords
#ChallengeResponseAuthentication yes
ChallengeResponseAuthentication no
# Kerberos options
#KerberosAuthentication no
#KerberosOrLocalPasswd yes
#KerberosTicketCleanup yes
#KerberosGetAFSToken no
#KerberosUseKuserok yes
# GSSAPI options
#GSSAPIAuthentication no
GSSAPIAuthentication yes
#GSSAPICleanupCredentials yes
GSSAPICleanupCredentials yes
#GSSAPIStrictAcceptorCheck yes
#GSSAPIKeyExchange no
# Set this to 'yes' to enable PAM authentication, account processing,
# and session processing. If this is enabled, PAM authentication will
# be allowed through the ChallengeResponseAuthentication and
# PasswordAuthentication. Depending on your PAM configuration,
# PAM authentication via ChallengeResponseAuthentication may bypass
# the setting of "PermitRootLogin without-password".
# If you just want the PAM account and session checks to run without
# PAM authentication, then enable this but set PasswordAuthentication
# and ChallengeResponseAuthentication to 'no'.
#UsePAM no
UsePAM yes
# Accept locale-related environment variables
AcceptEnv LANG LC_CTYPE LC_NUMERIC LC_TIME LC_COLLATE LC_MONETARY LC_MESSAGES
AcceptEnv LC_PAPER LC_NAME LC_ADDRESS LC_TELEPHONE LC_MEASUREMENT
AcceptEnv LC_IDENTIFICATION LC_ALL LANGUAGE
AcceptEnv XMODIFIERS
#AllowAgentForwarding yes
#AllowTcpForwarding yes
#GatewayPorts no
X11Forwarding no
#X11Forwarding yes
#X11DisplayOffset 10
#X11UseLocalhost yes
PrintMotd yes
PrintLastLog yes
#TCPKeepAlive yes
#UseLogin no
#UsePrivilegeSeparation yes
#PermitUserEnvironment no
#Compression delayed
#ClientAliveInterval 0
#ClientAliveCountMax 3
#ShowPatchLevel no
#UseDNS yes
#PidFile /var/run/sshd.pid
#MaxStartups 10:30:100
#PermitTunnel no
#ChrootDirectory none
# no default banner path
#Banner none
Banner /etc/ssh.banner.txt
# override default of no subsystems
Subsystem sftp /usr/libexec/openssh/sftp-server
# Example of overriding settings on a per-user basis
#Match User anoncvs
# X11Forwarding no
# AllowTcpForwarding no
# ForceCommand cvs server
AllowUsers root
AllowUsers admin