#!/usr/bin/env bash # Set up the Google Colab CLI in this environment (idempotent, no network auth). # # Installs the CLI + a persistent keyring backend, the OpenSSH client, an # ed25519 key, and prints the ~/.ssh/config stanza that bridges a Colab # runtime into VS Code Remote-SSH. It never signs in to Google and never # creates a Colab session — that is the user's step. set -u echo "== 1/4 Python ==" python3 --version echo "== 2/4 Install CLI + keyring backend ==" python3 -m pip install --quiet --upgrade google-colab-cli keyrings.alt python3 -c "import keyring; print('keyring backend:', keyring.get_keyring())" echo "== 3/4 OpenSSH client + key ==" command -v ssh >/dev/null || sudo apt-get install -y openssh-client mkdir -p "$HOME/.ssh" && chmod 700 "$HOME/.ssh" if [ ! -f "$HOME/.ssh/id_ed25519" ]; then ssh-keygen -t ed25519 -f "$HOME/.ssh/id_ed25519" -N "" -C "noeon-colab-cli" fi ssh-keygen -l -f "$HOME/.ssh/id_ed25519.pub" echo "== 4/5 VS Code Remote-SSH stanza ==" COLAB="$(command -v colab || echo "$HOME/.local/bin/colab")" if ! grep -q "Host colab-noeon" "$HOME/.ssh/config" 2>/dev/null; then cat >> "$HOME/.ssh/config" </dev/null; exec bash -l ServerAliveInterval 30 EOF chmod 600 "$HOME/.ssh/config" echo "added 'colab-noeon' to ~/.ssh/config" else echo "'colab-noeon' already in ~/.ssh/config" fi echo " WARNING: 'ProxyCommand ... -s noeon' CREATES the runtime on first" echo " connect. Add '--rm' to make it ephemeral, or pre-create it yourself." echo "== 5/5 VS Code Remote-SSH client extension ==" # code-server uses Open VSX; Microsoft's Remote-SSH is not published there. # jeanp413.open-remote-ssh is the open-source equivalent. ED="$HOME/.local/share/openhands-code-server/60001/extensions" if [ -d "$ED" ]; then /openhands/.code-server/lib/node /openhands/.code-server/out/node/entry \ --extensions-dir "$ED" --install-extension jeanp413.open-remote-ssh || true fi echo "Sign in to Google once with 'colab sessions' (see docs/COLAB_CLI.md)."