The Local App component in Gitpod provides tools for interacting with Gitpod workspaces from a user's local machine. It consists of two main applications: the Gitpod CLI (gitpod-cli) and the Local Companion App (gitpod-local-companion). These tools enable users to connect to their remote Gitpod workspaces, access ports, establish SSH connections, and manage workspaces from their local environment.
The primary purposes of the Local App component are:
- Provide a command-line interface for interacting with Gitpod
- Enable SSH access to Gitpod workspaces
- Establish secure tunnels to workspace ports
- Manage authentication and tokens for Gitpod access
- Support local development workflows with remote workspaces
- Enable port forwarding from workspaces to local machine
- Provide auto-updating capabilities for client tools
- Generate and manage SSH configurations
The Local App component consists of several key parts:
- Gitpod CLI: A command-line tool for interacting with Gitpod
- Local Companion App: A background service that maintains connections to workspaces
- Bastion: Core functionality for establishing and managing tunnels
- Authentication: Handles secure login and token management
- Self-update: Manages automatic updates of the client tools
The component is designed to work across multiple platforms (Linux, macOS, Windows) and architectures (amd64, arm64).
main/gitpod-cli/main.go: Entry point for the CLI applicationmain/gitpod-local-companion/main.go: Entry point for the Local Companion Apppkg/bastion/bastion.go: Core tunneling and connection managementpkg/auth/: Authentication and token managementpkg/selfupdate/: Self-update functionalitypkg/config/: Configuration managementpkg/helper/: Helper utilitiespkg/telemetry/: Telemetry collection
The Gitpod CLI provides various commands for interacting with Gitpod:
gitpod login: Authenticate with Gitpodgitpod workspace: Manage workspacesgitpod ssh: SSH into a workspacegitpod port: Forward ports from a workspacegitpod context: Manage Gitpod contexts (different Gitpod installations)gitpod completion: Generate shell completion scripts
The Local Companion App runs in the background and provides:
- Workspace Monitoring: Tracks running workspaces
- Port Tunneling: Automatically establishes tunnels to exposed ports
- SSH Access: Sets up SSH access to workspaces
- API Endpoint: Exposes a gRPC API for other tools to interact with
The tunneling system is a core feature that:
- Establishes SSH Connections: Creates secure SSH connections to workspaces
- Forwards Ports: Maps remote workspace ports to local ports
- Manages Visibility: Handles port visibility settings (public, private)
- Monitors Port Status: Tracks port status changes in workspaces
- Generates SSH Config: Creates SSH configuration for easy access
The authentication system:
- Manages Tokens: Securely stores and retrieves authentication tokens
- Handles Login Flow: Implements the OAuth login flow
- Uses System Keyring: Stores tokens in the system's secure keyring
- Validates Tokens: Ensures tokens are valid before use
The component includes a self-update mechanism that:
- Checks for Updates: Periodically checks for new versions
- Downloads Updates: Retrieves new versions when available
- Installs Updates: Replaces the current binary with the new version
- Maintains Versioning: Uses semantic versioning for updates
components/supervisor-api: For communicating with workspace supervisorcomponents/gitpod-protocol: For Gitpod API communicationcomponents/local-app-api: API definitions for the Local Appcomponents/public-api: Public API definitions
- SSH libraries for secure connections
- gRPC for API communication
- WebSockets for real-time communication
- System keyring for secure token storage
The Local App component integrates with:
- Gitpod Server: For authentication and workspace information
- Workspace Supervisor: For port information and terminal access
- IDE Proxy: For downloading client binaries
- Local System: For SSH configuration and port forwarding
The Local App is configured through:
- Command-line Flags: For immediate configuration
- Environment Variables: For persistent configuration
- Configuration File: Located at
~/.gitpod/config.yaml - SSH Configuration: Generated at a configurable location
The Local App implements several security measures:
- Secure Token Storage: Uses system keyring for token storage
- SSH Key Management: Generates and manages SSH keys securely
- Owner Token Validation: Ensures only workspace owners can connect
- Port Visibility Enforcement: Respects port visibility settings
The Local App component is typically used to:
- Connect to running workspaces via SSH
- Forward workspace ports to the local machine
- Manage workspaces from the command line
- Integrate Gitpod with local development tools
- Access workspace services from local applications
- Supervisor: Provides workspace information and port status
- IDE Proxy: Serves client binaries and updates
- Server: Handles authentication and workspace management
- Dashboard: Provides web UI for workspace management