IT Consultant – Java, J2EE, IBM WebSphere Portal, Lotus Notes/Domino
RSS icon Home icon
  • Determine the user who logged on via SSH

    1 Star2 Stars3 Stars4 Stars5 Stars
    Posted on 23 February 2009 Sebastian Thomschke*/?> No comments

    Today we had the need to determine the initial id of a user who logged onto a Linux box via SSH and executed the su command. When the su command is issued the effective user is changed and whoami or id commands will report that new user id instead.

    For anyone who is interested, that is what we came up to put the initial user id into a variable named ${LOGIN_USER}


    or alternatively

    LOGIN_USER=`who -m | cut -d' ' -f1`

    Leave a reply