Skip to content

Commit 336be78

Browse files
Bluevesanthosh-kt
authored andcommitted
[bash.bashrc] Add reverse SSH script to bash.bashrc (sonic-net#5438)
* [bash.bashrc] Add reverse SSH script to bash.bashrc * Fix command issue and add emptt line before EOF * Add checks for SSH_TARGET_CONSOLE_LINE Signed-off-by: Jing Kan jika@microsoft.com
1 parent 4ebb42a commit 336be78

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

files/image_config/bash/bash.bashrc

+17
Original file line numberDiff line numberDiff line change
@@ -56,3 +56,20 @@ fi
5656

5757
# Automatically log out console ttyS* sessions after 15 minutes of inactivity
5858
tty | grep ttyS >/dev/null && TMOUT=900
59+
60+
# if SSH_TARGET_CONSOLE_LINE was set, attach to console line interactive cli directly
61+
if [ -n "$SSH_TARGET_CONSOLE_LINE" ]; then
62+
if [ $SSH_TARGET_CONSOLE_LINE -eq $SSH_TARGET_CONSOLE_LINE 2>/dev/null ]; then
63+
# enter the interactive cli
64+
connect line $SSH_TARGET_CONSOLE_LINE
65+
66+
# test exit code, 1 means the console switch feature not enabled
67+
if [ $? -ne 1 ]; then
68+
# exit after console session ended
69+
exit
70+
fi
71+
else
72+
# exit directly when target console line variable is invalid
73+
exit
74+
fi
75+
fi

0 commit comments

Comments
 (0)