Prerequisites
- A private GitHub repository, and permission to read it.
- For the agent forwarding flow, SSH set up on your machine and a running job with SSH enabled. See Set up SSH and Connect over SSH.
- For the token flow, a GitHub personal access token with read access to the repository, and the Baseten CLI to store it as a secret.
With SSH agent forwarding
Agent forwarding works only over SSH. For a remote tunnel session, use the personal access token flow. To clone a private repository with agent forwarding:-
Load your GitHub-registered key into the local agent:
-
Connect to the job with agent forwarding, then confirm the container can reach GitHub:
GitHub’s reply names your account and confirms
You've successfully authenticated. -
Clone the repository over SSH from inside the container:
The command reports
Cloning into '<repo>'...and returns to your prompt when the clone finishes.
~/.ssh/config block written by baseten ssh setup doesn’t include ForwardAgent yes. Pass -A on every connection, or append ForwardAgent yes to the Match host training-job-*.ssh.baseten.co block in ~/.ssh/config.
The SSH agent forgets added keys on reboot. On macOS, add keys to your login keychain to reload them automatically:
AddKeysToAgent yes and UseKeychain yes in ~/.ssh/config. On Windows, the OpenSSH ssh-agent service keeps added keys across reboots.
With a personal access token
Pull the repository before you connect, for example fromstart_commands.
To clone a private repository with a personal access token:
-
Store a fine-grained GitHub personal access token with Contents: Read-only as a Baseten secret named
github_pat. -
Inject the secret in
config.py:Theconfig.pyx-access-tokenusername is GitHub’s convention for token-based HTTPS auth.$GITHUB_PATstays set for the container’s lifetime, so latergit pullorgit fetchcommands reuse the same credential. -
Pass
runtimeto theruntimeargument of the job in the same file. -
Push the job:
-
Read the job’s logs to confirm the clone landed:
The
git cloneinstart_commandsprintsCloning into '<repo>'..., and any later command that reads$BT_WORKING_DIR/repoprints its own output.
Next steps
- Connect to a training job over SSH: Open a shell in the container.
- Manage sessions: Check session status and change the trigger.