Skip to content

Commit 572862d

Browse files
committed
Print current time before SSH
1 parent e2df4c6 commit 572862d

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

ssh-oci-bastion.sh

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
set -e
33
set -o pipefail
44

5+
readonly VER=2.1.2
6+
57
# Remove the longest `*/` prefix
68
readonly SCRIPT_NAME_WITH_EXT="${0##*/}"
79

@@ -62,8 +64,7 @@ ENVIRONMENT
6264
ProxyJump
6365
\`\`\`
6466
65-
v2.1.1 May 2023 Created by Dima Korobskiy
66-
Credits: George Chacko, Oracle
67+
v$VER
6768
HEREDOC
6869
exit 1
6970
}
@@ -87,7 +88,7 @@ while getopts np:o:h OPT; do
8788
;;
8889
esac
8990
done
90-
echo -e "\n# \`$0 $*\`: run by \`${USER:-${USERNAME:-${LOGNAME:-UID #$UID}}}@${HOSTNAME}\`, in \`${PWD}\` #\n"
91+
echo -e "\n# \`$0${*+ }$*\` v$VER: run by \`${USER:-${USERNAME:-${LOGNAME:-UID #$UID}}}@${HOSTNAME}\` in \`${PWD}\` #\n"
9192
shift $((OPTIND - 1))
9293

9394
# Process positional parameters
@@ -125,7 +126,7 @@ done
125126

126127
readonly MAX_TTL=$((3 * 60 * 60))
127128
readonly CHECK_INTERVAL_SEC=5
128-
readonly AFTER_SESSION_CREATION_WAIT=6
129+
readonly AFTER_SESSION_CREATION_WAIT=7
129130

130131
# Determine which keypair ssh uses by default.
131132
# The default key order as of OpenSSH 8.1p1m (see `ssh -v {destination}`)
@@ -163,6 +164,8 @@ if [[ $port ]]; then
163164
ssh_command="${ssh_command/-i <privateKey>/}"
164165
# Replace the placeholder
165166
ssh_command="${ssh_command/<localPort>/localhost:$port}"
167+
168+
echo "Waiting $AFTER_SESSION_CREATION_WAIT seconds..."
166169
# Preventing intermittent `Permission denied (publickey)` errors when trying to ssh immediately after session creation
167170
sleep $AFTER_SESSION_CREATION_WAIT
168171

@@ -221,6 +224,8 @@ HEREDOC
221224
if [[ $SKIP_SSH ]]; then
222225
exit 0
223226
fi
227+
228+
echo "Waiting $AFTER_SESSION_CREATION_WAIT seconds..."
224229
# Preventing intermittent `Permission denied (publickey)` errors when trying to ssh immediately after session creation
225230
sleep $AFTER_SESSION_CREATION_WAIT
226231

0 commit comments

Comments
 (0)