[bash.bashrc] Add reverse SSH script to bash.bashrc (#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
This commit is contained in:
Blueve 2020-11-24 14:11:53 +08:00 committed by GitHub
parent e36c1fdb4d
commit 6a6e583b06
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -56,3 +56,20 @@ fi
# Automatically log out console ttyS* sessions after 15 minutes of inactivity
tty | grep ttyS >/dev/null && TMOUT=900
# if SSH_TARGET_CONSOLE_LINE was set, attach to console line interactive cli directly
if [ -n "$SSH_TARGET_CONSOLE_LINE" ]; then
if [ $SSH_TARGET_CONSOLE_LINE -eq $SSH_TARGET_CONSOLE_LINE 2>/dev/null ]; then
# enter the interactive cli
connect line $SSH_TARGET_CONSOLE_LINE
# test exit code, 1 means the console switch feature not enabled
if [ $? -ne 1 ]; then
# exit after console session ended
exit
fi
else
# exit directly when target console line variable is invalid
exit
fi
fi