Google Colab is not just a notebook. With the official Google CLI, google-colab-cli, you can open an SSH terminal on a Colab machine, with or without GPU, directly from your terminal, VS Code, or any editor that speaks SSH.
In this article: install the CLI, configure ~/.ssh/config, perform the first login, and connect/disconnect without wasting compute units.
What You Need
- A Google account with access to Colab (Google AI Subscription - Plus, Pro, or Ultra)
- Python 3 with uv or pip
- OpenSSH, which comes pre-installed on Linux, macOS, and Windows 10/11
- An ed25519 SSH key
1. Install the Colab CLI
The official package is called google-colab-cli and installs the colab command.
1uv tool install google-colab-cli2# or: pip install google-colab-cli3colab version

2. Have an SSH Key
When connecting, colab sends your public key to the machine. By default, it looks for ~/.ssh/id_ed25519.pub or id_ecdsa.pub. Don't have one yet?
1ssh-keygen -t ed25519
Using a key with a different name? No problem: you point to it in the next step using -i.
3. Add the Host to ~/.ssh/config
Open (or create) the ~/.ssh/config file and paste this block:
1Host colab2 User root3 ProxyCommand colab ssh --proxy-mode -s colab -i ~/.ssh/id_ed25519.pub4 StrictHostKeyChecking no5 UserKnownHostsFile /dev/null

What each line does:
- Host colab: The nickname. After this, just type
ssh colab. - ProxyCommand: Instead of opening a connection to an IP, SSH talks to
colab ssh --proxy-mode, which bridges to the Colab machine. The-s colabis the session name: if it doesn't exist, the CLI creates it. - StrictHostKeyChecking no and UserKnownHostsFile /dev/null: Each session is a new machine with a new host key. Without this, SSH complains at every connection.
Two pitfalls that cost me time:
- If your config has a Host block, place colab before it. In SSH, the first value found is the one that counts: a `StrictHostKeyChecking no` under `Host ` above overrides the one for colab.
- On Windows, use the absolute path for the key in
-i(C:/Users/you/.ssh/id_ed25519.pub). The~inside the ProxyCommand is not expanded.
4. Perform the First Login in a Real Terminal
The first time, the CLI asks for authorization from your Google account: it shows a link, you approve it in the browser, and paste back the code displayed by Google.
1colab new -s colab

Attention: Do this first login in an interactive terminal (PowerShell, Terminal, iTerm). If the first ssh colab comes from something without a keyboard, like an AI agent, a script, or a command triggered from within a chat, the CLI has nowhere to read the code and the login fails with "Malformed auth code". Once the login is saved, anywhere works.
Want GPU? Create the session with it already: colab new -s colab --gpu T4. It also accepts L4, A100, and H100, and --high-mem for more RAM.
5. Connect
1ssh colab

You land as root in /content, on Ubuntu 24.04. The non-GPU session in the screenshot has 2 vCPUs, 12 GB of RAM, and about 226 GB of disk.
You can also run a single command without opening the shell:
1ssh colab "nvidia-smi"
And since it's standard SSH, VS Code (Remote - SSH), scp, rsync, and any editor with remote machine support see the colab host without extra configuration.
6. Shut Down When Finished
The session consumes compute units while powered on, even if idle. Done? Stop it and check:
1colab stop -s colab2colab sessions3colab usage

To avoid relying on memory, the CLI has --rm, which stops the session when SSH closes. Just add it to the ProxyCommand:
1ProxyCommand colab ssh --proxy-mode -s colab --rm -i ~/.ssh/id_ed25519.pub
Duration and Cost
- Each machine type consumes units at its own rate. Non-GPU is almost nothing; T4 runs around 1.8 per hour, L4 at 4.8, and A100 at 11 to 13. Values change: check with
colab usagewhile the session is on. - Sessions have a time cap (up to about 24 h on Pro) and drop due to inactivity.
- Disk is disposable. When the session ends, everything disappears. Git push or copy your files before (scp, rsync, or
colab download), or mount Google Drive withcolab drivemount.
CLI Commands Worth Memorizing
- colab sessions: Lists active sessions
- colab status: Session state
- colab usage: Balance and usage rate
- colab upload / colab download: Send and fetch files
- colab drivemount: Mounts Google Drive on the machine
- colab stop -s <name>: Stops the session
Done: Colab becomes just another host in your ~/.ssh/config. One ssh colab and you're on a Linux machine with GPU, paying only for the time it stays on.





