bash - How can I list the SSH connection sequence on a remote computer? -
suppose working on locala
(username usera
). use ssh
tunnel remoteb
(username userb
), remotec
(username userc
), remotedestinationd
(username userd
).
it following:
usera@locala$ ssh userb@remoteb userb@remoteb$ ssh userc@remotec userc@remotec$ ssh userd@remotedestinationd userd@remotedestinationd$
suppose forget series of connections used connect locala
remotedestinationd
. have been 1 jump (e.g. usera@locala$ ssh userd@remotedestinationd
) or 3 jumps (as in example above). how programmatically determine series of jumps was? ("scroll through history, dummy!" doesn't count....)
i'd bash script output following:
usera@locala$ --> userb@remoteb userb@remoteb$ --> userc@remotec userc@remotec$ --> userd@remotedestinationd
any ideas?
thanks in advance!
there no way this, suspect. there bunch of true hacks if willing, such turning on x11 port forwarding , using different ports counting.
or, more obnoxiously:
sshcount=0 ssh usera@remotea "echo sshcount=$(($sshcount+1)) > .bashrc; bash"
and there similar b, sshcount keeps incrementing.
clearly should done via overwriting .sshcountrc
file or something, , source .bashrc
. , then, might need make file name dependent on munging of $ssh_tty
if want support doing parallel versions of this.
and whole thing hack maybe shouldn't anyway , should solve problem way. or remove need counting in first place.
Comments
Post a Comment