Find the answer to your Linux question:
Results 1 to 6 of 6
Hi All, I am using SSH - OpenSSH_3.6.1p2, SSH protocols 1.5/2.0, OpenSSL 0x0090701f. I have a requirement that when ever any user login to the system, User has to get ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Nov 2006
    Posts
    3

    SSH: How to Display user last successful login


    Hi All,

    I am using SSH - OpenSSH_3.6.1p2, SSH protocols 1.5/2.0, OpenSSL 0x0090701f.

    I have a requirement that when ever any user login to the system, User has to get last successful login information. Right now only root user able to show this message.

    I am expecting following message for all the users...

    $ login: testuser
    $ password:
    Last login: Fri Nov 21 08:40:09 2006 from 123.345.432.94

    I have modify /etc/pam.d/sshd and /etc/pam.d/login files and added following line in those files

    session optional pam_lastlog.so

    After that SSH has been restarted still i am unable to see the last successful login information for other users.

    I don't know where problem with SSH configuration or SSH version not support this feature?

    Any pointers can be helpfully for me.....

    Regards,
    Sri

  2. #2
    Linux User
    Join Date
    Aug 2006
    Location
    Croydon, PA
    Posts
    392
    Try this command:

    lastlog -u <username>
    Good Luck,
    Ski
    RHCT

  3. #3
    Just Joined!
    Join Date
    Nov 2006
    Posts
    3
    Hi Skiboy....

    By using "lastlog -u <username>" command, user come to no about the last successful login information.... But I required this information automatically after user login to the system...The means after enter the password for the given user.

    Regards,
    Sri

  4. $spacer_open
    $spacer_close
  5. #4
    Linux User
    Join Date
    Aug 2006
    Location
    Croydon, PA
    Posts
    392
    I can only think of doing this in the .bashrc file in the home directory of each user. You might be able to do it in the /etc/profile but I'm not sure.
    The following is what you would add to the end of the.bashrc file in the home directory.

    # last login
    num=0
    last | grep $USER | head -2|while read line
    do
    ((num=num+1))
    if [ $num -eq 2 ] ; then
    echo $line
    fi
    done
    Good Luck,
    Ski
    RHCT

  6. #5
    Just Joined!
    Join Date
    Nov 2006
    Posts
    3
    Thanks Skiboy....

    Profile modification is working.... However is there anyway to use pam_lastlog.so in PAM.D configuration.

    Regards,
    sri

  7. #6
    Linux User
    Join Date
    Aug 2006
    Location
    Croydon, PA
    Posts
    392
    Not really sure what you are asking.
    "last" and "lastlogin" get theinfo from PAM.
    Good Luck,
    Ski
    RHCT

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •