If you have Google Cloud SDK installed, you can interact with Cloud Shell directly from your terminal and use it as a sandbox and a portable development environment! This provides the convenience of working with Cloud Shell resources, whether to quickly test an operation or use an IDE of your choice to edit a file saved on your Cloud Shell instance from the comfort of your local desktop.
gcloud cloud-shell command group offering provides the following
- Establishing an interactive SSH session with Cloud Shell using
gcloud alpha cloud-shell ssh.
- Copy files between your local and Cloud Shell machine via scp.
- Mount your Cloud Shell directory to your local file system via sshfs.
For more detail, see the reference documentation for
gcloud alpha cloud-shell.
To illustrate the workings of
gcloud cloud-shell, here is an example of how
you can use these commands in practice:
Start a SSH session:
gcloud alpha cloud-shell ssh
Copy a file, 'data.txt', from Cloud Shell to your local machine:
gcloud alpha cloud-shell scp cloudshell:~/data.txt localhost:~data.txt
If you're using Mac or Linux, you can mount your Cloud Shell home directory onto your local file system after installing sshfs.
This allows you to edit the files in your Cloud Shell home directory using your choice of local tools. All the data in your remotely mounted file system is stored on a Persistent Disk and stored across sessions.
gcloud alpha cloud-shell get-mount-command ~/my-cloud-shell