Skip to content

Commit 36dd489

Browse files
committed
Print current time before SSH
1 parent c6d7224 commit 36dd489

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

ssh-oci-bastion.sh

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ if [[ ! $SSH_PUB_KEY ]]; then
144144
fi
145145

146146
if [[ $port ]]; then
147-
echo -e "\nCreating a port forwarding tunnel for the port $port: this can take 15-25s ..."
147+
echo -e "\nCreating a port forwarding tunnel for the port $port: this can take ≈ 10-20s ..."
148148
# `--session-ttl`: session duration in seconds (defaults to 30 minutes, maximum is 3 hours).
149149
# `--wait-interval-seconds`: state check interval (defaults to 30 seconds).
150150
# `--ssh-public-key-file` is required
@@ -154,7 +154,7 @@ if [[ $port ]]; then
154154
--target-resource-id "$OCI_INSTANCE_OCID" --target-port "$port" \
155155
--session-ttl $MAX_TTL --ssh-public-key-file $SSH_PUB_KEY --wait-for-state SUCCEEDED --wait-for-state FAILED \
156156
--wait-interval-seconds $CHECK_INTERVAL_SEC | jq --raw-output '.data.resources[0].identifier')
157-
echo "Bastion Port Forwarding Session OCID=$session_ocid"
157+
echo "Created the bastion port forwarding session: $session_ocid"
158158

159159
# shellcheck disable=SC2086 # $PROFILE_OPT is a two-word CLI option
160160
ssh_command=$(oci bastion session get $PROFILE_OPT --session-id "$session_ocid" |
@@ -166,7 +166,7 @@ if [[ $port ]]; then
166166
ssh_command="${ssh_command/<localPort>/localhost:$port}"
167167
sleep $AFTER_SESSION_CREATION_WAIT
168168

169-
echo -e "\n$(date +'%T %Z') Opening an SSH tunnel. Interrupt (Ctrl+C) the process to close it."
169+
echo -e "\n[$(date +'%T %Z')] Opening an SSH tunnel. Interrupt (Ctrl+C) the process to close it."
170170
set -x
171171
# This only works assuming there are no internal quotes in the command
172172
$ssh_command
@@ -175,7 +175,7 @@ if [[ $port ]]; then
175175
fi
176176

177177
if [[ $HOST_USER ]]; then
178-
echo -e "\nCreating a bastion session: this can take 1m:15s-1m:30s ..."
178+
echo -e "\nCreating a bastion session: this can take 1m:13s-1m:30s ..."
179179
# `--session-ttl`: session duration in seconds (defaults to 30 minutes, maximum is 3 hours).
180180
# `--wait-interval-seconds`: state check interval (defaults to 30 seconds).
181181
# `--ssh-public-key-file` is required
@@ -184,7 +184,7 @@ if [[ $HOST_USER ]]; then
184184
--target-resource-id "$OCI_INSTANCE_OCID" --target-os-username "$HOST_USER" --session-ttl $MAX_TTL \
185185
--ssh-public-key-file $SSH_PUB_KEY --wait-for-state SUCCEEDED --wait-for-state FAILED \
186186
--wait-interval-seconds $CHECK_INTERVAL_SEC | jq --raw-output '.data.resources[0].identifier')
187-
echo "Bastion Session OCID=$session_ocid"
187+
echo "Created the bastion session: $session_ocid"
188188

189189
# shellcheck disable=SC2086 # $PROFILE_OPT is a two-word CLI option
190190
ssh_command=$(oci bastion session get $PROFILE_OPT --session-id "$session_ocid" |
@@ -223,8 +223,8 @@ HEREDOC
223223
fi
224224
sleep $AFTER_SESSION_CREATION_WAIT
225225

226-
echo -e "\n$(date +'%T %Z') SSH to the target instance via a jump host"
226+
echo -e "\n[$(date +'%T %Z')] SSH to the target instance via a jump host"
227227
set -x
228228
ssh "${HOST_USER}@${OCI_INSTANCE}"
229229
set +x
230-
fi
230+
fi

0 commit comments

Comments
 (0)