# Use Cloud Shell with the gcloud CLI

If you have the [gcloud CLI installed](https://docs.cloud.google.com/sdk/install), you can interact
with Cloud Shell 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 your local desktop.

## Use `gcloud cloud-shell`

The current `gcloud cloud-shell` command group offering provides the following
functionality:

- Establishing an interactive SSH session with Cloud Shell using [`gcloud cloud-shell ssh`](https://docs.cloud.google.com/sdk/gcloud/reference/cloud-shell/ssh.md.txt).
- Copy files between your local and Cloud Shell machine via [scp](https://docs.cloud.google.com/sdk/gcloud/reference/cloud-shell/scp.md.txt).
- Mount your Cloud Shell directory to your local file system via [sshfs](https://docs.cloud.google.com/sdk/gcloud/reference/cloud-shell/get-mount-command.md.txt).

For more detail, see the reference documentation for
[`gcloud cloud-shell`](https://docs.cloud.google.com/sdk/gcloud/reference/cloud-shell.md.txt).

> [!NOTE]
> **Note:** To propagate your credentials to your Cloud Shell when starting it from the Google Cloud CLI, use the [`--authorize-session`](https://docs.cloud.google.com/sdk/gcloud/reference/cloud-shell/ssh.md.txt#--authorize-session) flag when running the `gcloud cloud-shell ssh` command.

## Example workflow

To illustrate the workings of `gcloud cloud-shell`, here is an example of how
you can use these commands in practice:

1. Start a SSH session:

       gcloud cloud-shell ssh

2. Copy a file, `data.txt`, from Cloud Shell to your local machine:

       gcloud cloud-shell scp cloudshell:~/data.txt localhost:~data.txt

3. If you're using Mac or Linux, you can mount your Cloud Shell home
   directory onto your local file system after installing
   [sshfs](https://github.com/libfuse/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](https://docs.cloud.google.com/persistent-disk)
   and stored across sessions.

       gcloud cloud-shell get-mount-command ~/my-cloud-shell