Print ssh and su chain
        Posted  
        
            by 
                user1824885
            
        on Super User
        
        See other posts from Super User
        
            or by user1824885
        
        
        
        Published on 2012-11-14T20:39:50Z
        Indexed on 
            2012/11/15
            11:09 UTC
        
        
        Read the original article
        Hit count: 315
        
bash
Is there a way to show the complete ssh and su chain in bash?
For example. In Server A as user aa:
su - ab
ssh ba@B
su - bb
Thus, I would like a command that prints something like this:
1 bash aa in A
2 su ab in A
3 ssh ba in B
4 su bb in B
I tried pstree but it does not print the users and only works with the processes of the last ssh'ed server:
$ pstree | grep -C 5 pstree
serversshd---sshd---sshd---bash---su---bash-+-grep
     |                                       `-pstree
Thanks and regards.
© Super User or respective owner