Google Cloud Shell is an interactive shell environment for Google Cloud
Platform. It makes it easy for you to manage your projects and resources without
having to install the Google Cloud SDK and other tools on your
system. With Cloud Shell, the Cloud SDK
tool and other utilities you need are always available when you need them.
Cloud Shell provides the following:
- A temporary Compute Engine virtual machine instance
- Command-line access to the instance from a web browser
- Built-in code editor BETA
- 5 GB of persistent disk storage
- Pre-installed Google Cloud SDK and other tools
- Language support for Java, Go, Python, Node.js, PHP, Ruby and .NET
- Web preview functionality
- Built-in authorization for access to GCP Console projects and resources
- Customized environments ALPHA
Virtual machine instance
When you start Cloud Shell, it provisions a g1-small Google Compute Engine virtual machine running a Debian-based Linux operating system. Cloud Shell instances are provisioned on a per-user, per-session basis. The instance persists while your Cloud Shell session is active and terminates after an hour of inactivity.
Cloud Shell provides command-line access to the virtual machine instance in a
terminal window that opens in the Google Cloud Platform Console. You can open multiple
shell connections to the same instance. The instance persists between sessions.
In addition to accessing the Cloud SDK
tool and other utilities from the command line, you can use the
command to launch tutorials, open the code editor, and download files. Run
cloudshell help for more information.
The beta version of Cloud Shell code editor running Theia is now available for use.
You can use the code editor to browse file directories as well as view and edit files, with continued access to the Cloud Shell. The code editor is available by default with every Cloud Shell instance.
You can access the code editor from the toolbar by clicking the pencil icon.
Alternatively, you can open an existing file - for example,
README-cloudshell.txt from the environment above - in the code editor by running
cloudshell command in your Cloud Console as such:
cloudshell edit README-cloudshell.txt
Persistent disk storage
Cloud Shell provisions 5 GB of free
persistent disk storage mounted as
$HOME directory on the virtual machine instance. This storage is on
a per-user basis and is available across projects. Unlike the instance itself,
this storage does not time out on inactivity. All files you store in your
home directory, including installed software, scripts and user configuration
.vimrc, persist between sessions. Your
directory is private to you and cannot be accessed by other users.
The Cloud Shell virtual machine instance has the following pre-installed tools:
|Linux shell interpreters||
|Linux utilities||Standard Debian system utilities|
|Google SDKs and tools||
Google App Engine SDK
Google Cloud SDK including the
|Build and package tools||
|Source control tools||
You can install additional software packages on the virtual machine instance
but the installation will not persist after the instance terminates unless you
install the software in your
The Cloud Shell virtual machine instance provides pre-installed language support for the following:
|Java||JRE/JDK 1.7 and 1.8|
|.NET Core||SDKs 2.0.0 and 2.1.502
Core runtimes 2.0.0 and 2.1.6
The default version of the Java environment is 1.8. To change the current Cloud Shell session to use version 1.7 of the JRE and JDK, enter the following at the Cloud Shell command prompt:
sudo update-java-alternatives -s java-1.7.0-openjdk-amd64 && export JAVA_HOME=/usr/lib/jvm/java-7-openjdk-amd64/jre
To change back to 1.8.0:
sudo update-java-alternatives -s java-1.8.0-openjdk-amd64 && export JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64/jre
You can ignore any error messages about not being able to change the
versions of some binaries. The version change will persist until the
Cloud Shell virtual machine instance is terminated. If you want to
permanently switch to Java 1.7, add the first command above to your
Cloud Shell provides web preview functionality that allows you to run web applications on the virtual machine instance and preview them from the GCP Console. The web applications must listen for HTTP requests on ports within the permitted range 2000 to 65000. These ports are only available to the secure Cloud Shell proxy service, which restricts access over HTTPS to your user account only.
To connect to a web application running on an instance, click the Web Preview button above the Cloud Shell terminal window in the GCP Console. Then, select the port number from the displayed menu. This opens a preview URL on the Cloud Shell proxy service in a new browser window.
Boost mode temporarily increases the power of your Cloud Shell VM - from the default g1-small machine type offering to a n1-standard-1 VM instance. This is handy if you'd like to continue working on Cloud Shell and need more CPU or memory resources for a relatively short period of time.
To activate boost mode, find the 'Enable Boost Mode' option under the 'More' menu (the three dotted icon on the top right of Cloud Shell). Once activated, all sessions will be boosted for the next 24 hours. Enabling Boost mode restarts your Cloud Shell and will immediately terminate your session. A new VM will then be provisioned for you which can take a couple of minutes. The data in your home directory will persist, but all running processes will be lost.
Boost mode is subject to regular usage limits. Currently, this feature is experimental and additional limits may be implemented in the future.
Cloud Shell provides built-in authorization for access to projects and
resources hosted on Google Cloud Platform. You don't need to perform additional
authorization steps to access platform resource using the Cloud SDK
Cloud Shell uses
tmux by default, which allows it to improve
persistence across browser tab sessions. For example, if you refresh the
GCP Console in a tab or connect to your Cloud Shell from a
different machine, the session state will not be lost.
Cloud Shell supports the default
tmux key bindings. For
example, if you press Ctrl+b and then %,
tmux splits the current
session window into left and right panes, which can be useful for debugging.
tmux in Cloud Shell, click the Settings button
, select Tmux
Settings and de-select the Enable Tmux Integration option.
Terminal usage statistics
Cloud Shell collects anonymized usage statistics on commands that are run inside the Cloud Shell terminal. We only collect usage statistics on commands that come pre-installed in the Cloud Shell. We do not collect any metrics on personally identifiable information, such as arguments passed to these commands. These metrics cannot be tied back to your account. To disable collection, select Usage Statistics in Cloud Shell Settings (using the three dots menu icon).
Note: This is separate from gcloud usage statistics, which is enabled by default in the Cloud Shell.
Cloud Shell will immediately close after connection if there is a problem in
.tmux.conf files. To
resolve this, open Cloud Shell in safe mode by appending
cloudshellsafemode=true to the URL. This will restart your Cloud
Shell and log you in as root, allowing you to fix any issues in the files.
Cloud Shell allows you to alter what keys are sent to the terminal. Under the Terminal Settings menu, select Terminal Preferences > Keyboard to see the following options:
- Alt is Meta - Set whether the alt key acts as a meta key or as a distinct alt key.
- Alt Gr Mode - Select an AltGr detection heuristic
Custom Cloud Shell environment
Your Cloud Shell environment is a Docker container and with the custom environment feature, currently in alpha, you can now modify this container by editing a Dockerfile. This enables you to install custom tooling into your Cloud Shell environment that persists between sessions. The environment configuration page can be found here
Clicking "Create custom image" on the configuration screen launches a tutorial that walks you through the process of creating a custom Docker image to use as your Cloud Shell environment. You can then edit your Cloud Shell environment to reference this newly created image.
This tutorial automatically creates four resources:
- A Cloud Source Repositories repo containing your Dockerfile.
- Two Cloud Build build triggers, one that triggers on any update to the Cloud Source Repositories repo, and the other that triggers on Cloud Shell base image chages.
- The built Docker image hosted in Google Container Registry.
If you wish to clean up after the tutorial, you will need to delete these resources from Cloud Source Repositories, Cloud Build and Container Registry.
Custom Environment Limitations
- The custom image must be based off the default Cloud Shell image: gcr.io/cloudshell-images/cloudshell
- Variables specified by ENV in your Dockerfile will not be propagated to the
SSH session. To propagate these to the SSH session, set these variables in
the /etc/environment file:
RUN echo "$MY_VAR=$DESIRED_VALUE" >> /etc/environment
- You cannot override the Dockerfile ENTRYPOINT.
- Place scripts you would like to run at session start under /google/devshell/bashrc.google.d/. Script to be run on session end can be placed under /google/devshell/bash_exit.google.d/.