Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I have three machines A,B,C. If I ssh into B from A, then into C from B, how can I find the path A->B->C ?

I'd like to display this information in the prompt in order to know where I'm going to land when I exit ssh .

share|improve this question

1 Answer 1

You can look at ssh connections with lsof and try to figure out where are you connected from right now.

For example:

lsof -i:ssh
root@prmox01:~# lsof -i:ssh
COMMAND   PID USER   FD   TYPE DEVICE SIZE/OFF NODE NAME
sshd     1404 root    3u  IPv4   9601      0t0  TCP *:ssh (LISTEN)
sshd     1404 root    4u  IPv6   9603      0t0  TCP *:ssh (LISTEN)
sshd    66653 root    3r  IPv4 167143      0t0  TCP prmox01.example.ru:ssh->192.168.25.178:43406 (ESTABLISHED)
share|improve this answer
    
This would work if I could set a remote variable when I ssh into the machine, otherwise I will only get the last hop of the path, but I want the whole path (A->B->C) –  Antoine Lecaille Aug 4 '12 at 10:28

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.