Last active
January 29, 2022 22:46
-
-
Save jjo/a19d19e589f8db6fa6faacda7128f36e to your computer and use it in GitHub Desktop.
ssh config stanza to use `gcloud beta ssh ...` straight via `ssh` CLI
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### Add below stanza to your ~/.ssh/config | |
## Parsed as vmname.REGION.PROJECT.gcp | |
Host *.*.*.gcp | |
ProxyCommand gcloud beta compute ssh --tunnel-through-iap $(echo %h|awk -v FS=. '{ printf ("--project=%%s --zone=%%s %%s", $3, $2, $1) }') --command="nc -q0 localhost 22" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Plain ssh against some VM (replace vm-name, some-project names below) | |
$ ssh vm-name.us-central1-a.some-project.gcp uname -r | |
4.19.0-18-cloud-amd64 | |
# Or use any other ssh- backed tool, e.g:. | |
$ rsync vm-name.us-central1-a.some-project.gcp: | |
# SSH agent forwarding ftW | |
$ ssh -A vm-name.us-central1-a.some-project.gcp | |
## At VM prompt: | |
vm-name $ git clone git@github:foo/private-repo |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment