Skip to content

Commit

Permalink
scripts: simplify (fix) gceworker mosh
Browse files Browse the repository at this point in the history
At least on my machine, we need to use the $FQNAME because that has the
corresponding section in the ssh config specifying the correct public
key (maintained via `gcloud [...] config-ssh`.

Release note: None
  • Loading branch information
tbg committed Jan 27, 2022
1 parent f918e4b commit 486be25
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions scripts/gceworker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -100,18 +100,14 @@ case "${cmd}" in
echo "****************************************"
echo "Hint: you should also be able to directly invoke:"
echo "ssh ${FQNAME}"
echo " or"
echo "mosh ${FQNAME}"
echo "instead of '$0 ssh'."
echo "****************************************"
gcloud compute ssh "${NAME}" --ssh-flag="-A" "$@"
;;
mosh)
# An alternative solution would be to run gcloud compute config-ssh after
# starting or creating the vm, which adds stanzas to ~/.ssh/config that
# make `ssh $HOST` (and by extension, hopefully, mosh).
read -r -a arr <<< "$(gcloud compute ssh "${NAME}" --dry-run)"
host="${arr[-1]}"
unset 'arr[${#arr[@]}-1]'
mosh --ssh=$(printf '%q' "${arr}") $host
mosh "${FQNAME}"
;;
scp)
# Example: $0 scp gceworker-youruser:go/src/github.com/cockroachdb/cockroach/cockroach-data/logs gcelogs --recurse
Expand Down

0 comments on commit 486be25

Please sign in to comment.