Is it possible to use the Google Cloud Shell via a ssh?

27.1k views Asked by At

Is it possible to connect to the Google Cloud Shell instance via the ssh? Maybe somehow with gcloud? So I can use it with my favorite terminal (iTerm in particular) and not with the Web-based shell.

Answer: yes it is now been possible: https://cloud.google.com/blog/products/gcp/introducing-the-ability-to-connect-to-cloud-shell-from-any-terminal

3

There are 3 answers

0
41bin On

Yes, you can do that with 3 simple steps:

  1. open a terminal in your local system
  2. install google-cloud-sdk : sudo snap install google-cloud-sdk --classic
  3. Authenticate google-cloud-sdk with your google account : gcloud auth login NOTE : After running this command , your default browser will be open and will ask you to authenticate
  4. After the autherization, go back to the terminal and run the following commad to get access into the shell : gcloud cloud-shell ssh NOTE : If you are doing this first time, it may walk you through creating ssh keys, if it's happen, in my case, i continue with empty password
  5. So, whenever you need that cloud shell , just run : gcloud cloud-shell ssh
0
untore On

You can connect to a vpn from the cloud shell, put the needed binary in your home directory and write the necessary startup scripts (connect to vpn and start daemon etc) on top of the .bashrc file so that it get executed when you start the shell from your browser.

I also suggest to use mosh becasue routing this way is pretty terrible and maybe run ssh cipherless since the vpn is already encrypted.

You could also cobble the heartbeat to keep the shell alive but that's probably too much in abuseland, having a pinned tab for the cloud shell seems good enough to me.

3
Travis Webb On

Yes. From the gcloud CLI, run gcloud cloud-shell ssh. This will establish an interactive SSH session with Cloud Shell.

Reference: