# Use several GitHub identities on one workstation

> For the complete documentation index, see [llms.txt](https://docs.ringleader.dev/llms.txt).


> Let one workstation act as more than one GitHub account or app, and choose the identity for each request, while none of their tokens is on the workstation.


Let one workstation act as more than one GitHub account or app, and choose the identity for each
request, while none of their tokens is on the workstation. Use this when you push your own work as
yourself and let a coding agent open pull requests as a bot account, or when two GitHub Apps each
reach different repositories. Each identity is its own GitHub Integration. A request names the one it
wants with a placeholder, and Ringleader adds that Integration's token as the request leaves the
workstation.

## Prerequisites

- [Ringleader installed](https://docs.ringleader.dev/install/), with the Ringleader application
  running.
- The workstation and Integration from
  [Give a workstation access to GitHub](https://docs.ringleader.dev/guides/github-access/): a workstation on
  your computer named `my-git-box`, labeled `role: agent`, and the Integration `my-github` that adds
  your token. Replace the names with yours.
- A GitHub personal access token for the second identity, such as a bot account, that can read the
  repository you clone below.
- `git` 2.46 or later on the workstation for the `git` step. Debian 13, the default image, has a
  newer one, and Ubuntu 24.04 has 2.43. Run `git --version` on the workstation to check.

## Add a second identity

Store the second token in a Secret, then apply a second GitHub Integration. Your first Integration
stays the default, so a request that names no identity keeps using your own token.

1. Store the token in a Secret named `github-bot-pat`:

   ```bash
   rl secret create github-bot-pat -n local --from-string token=<bot-token>
   ```

2. Save this as `my-github-bot.yaml`. It reaches the same workstations as `my-github`, and
   `default: false` makes it answer only requests that name it:

   ```yaml
   apiVersion: workstations.ringleader.dev/v1
   kind: Integration
   metadata:
     name: my-github-bot
     namespace: local
   spec:
     type: httpProxy
     selector:
       matchLabels:
         role: agent
     httpProxy:
       vendor: github
       default: false
       credentialRef:
         name: github-bot-pat
         key: token
   ```

3. Apply the file:

   ```bash
   rl apply -f my-github-bot.yaml
   ```

4. Wait until the workstation has applied it:

   ```bash
   rl workstation wait my-git-box --for Configured --timeout 10m -n local
   ```

   The command returns once the workstation's `Configured` condition is `True`.

## Choose an identity for a request

Each GitHub Integration has a placeholder: `rlsel-` followed by the Integration's name. The
placeholder for `my-github-bot` is `rlsel-my-github-bot`. When a request to GitHub carries a
placeholder in its `Authorization` header, Ringleader replaces the whole header with that
Integration's token. A request with no placeholder gets the default Integration's token, here
`my-github`'s.

These steps make one request with each tool, as the bot account:

1. Open a shell on the workstation:

   ```bash
   rl shell my-git-box -n local
   ```

2. Call the GitHub API with `curl`, sending the placeholder as a bearer token:

   ```bash
   curl -H "Authorization: Bearer rlsel-my-github-bot" https://api.github.com/user
   ```

   The response's `login` is the bot account. The same call without the header returns your own
   account.

3. Optional: Call the API with the GitHub CLI, if the workstation has the
   [`gh` devtool](https://docs.ringleader.dev/reference/tools/devtools/gh/). `gh` sends the value of
   `GH_TOKEN` in its `Authorization` header:

   ```bash
   GH_TOKEN=rlsel-my-github-bot gh api user --jq .login
   ```

   The command prints the bot account's login.

4. Clone a repository with `git`, with the placeholder as the password in the URL:

   ```bash
   git clone https://my-github-bot:rlsel-my-github-bot@github.com/your-org/your-app.git
   ```

   The clone runs as the bot account. `git` saves this URL as the repository's remote, so a later
   `git push` or `git pull` in that folder runs as the bot account too. A `git clone` with no
   placeholder in the URL still runs as you.

If that is all you need, you are done. The sections below say where to find a placeholder, how to
choose the default identity, and what to do when a request does not use the identity you expect.

## Find an Integration's placeholder

Ringleader shows each GitHub Integration's placeholder, and whether it is the default, in three
places:

- `rl integration describe my-github-bot -n local` prints them under `Status`:

  ```text
  Status:
    Default:    false
    GeneratedConfig: integration-my-github-bot
    Placeholder: rlsel-my-github-bot
  ```

- In the Ringleader console, the page of an Integration in one of your namespaces shows
  **Placeholder** and **Default** rows.
- On the workstation, `/etc/ringleader/integrations/my-github-bot.json` holds them for a program to
  read. The workstation's login user and `root` can read the file:

  ```json
  {
    "schemaVersion": 1,
    "name": "my-github-bot",
    "namespace": "local",
    "type": "httpProxy",
    "vendor": "",
    "httpProxy": {
      "vendor": "github",
      "placeholder": "rlsel-my-github-bot",
      "default": false,
      "hosts": [
        "api.github.com",
        "github.com",
        "raw.githubusercontent.com"
      ],
      "gitHost": "github.com"
    }
  }
  ```

A placeholder is not a secret. You can put it in a script, an environment variable or a log. It
picks a token only on a workstation the Integration already reaches, and every program on such a
workstation can already use that token. On any other workstation it picks nothing.

## Choose the default identity

`httpProxy.default` says whether an Integration's token goes on requests that carry no placeholder,
such as a plain `git clone` or `curl`. It is `true` when you leave it out, and it is accepted only
beside `vendor: github`. Keep exactly one GitHub Integration as the default on each workstation, and
set `default: false` on the others.

If two GitHub Integrations that reach one workstation are both the default, neither is. A request
with no placeholder goes to GitHub with no token, so cloning a private repository fails or asks for
a password. A request with a placeholder still gets its Integration's token. It gets none if the
edge instance, edge VM or network process that serves the workstation runs a Ringleader version
older than placeholders. Ringleader reports the clash as `DefaultContested`:

- `rl workstation describe my-git-box -n local` lists each GitHub host under
  **Credential injection** as not injecting, and says that another Integration also claims to be the
  default.
- `rl integration describe <name>` says the same for each of the two Integrations when an Edge your
  namespace declares serves the workstation, as one serves every cloud workstation. For a workstation
  on your computer with no Edge declared, only the workstation reports it.

The workstation keeps working, and no condition changes. To fix it, set `default: false` on one of
the two Integrations and apply it again.

An Integration with `default: false` writes no `gh` configuration, even when it lists
`toolconfigs: [{name: gh}]`. When several GitHub Integrations write one, `gh` uses the placeholder of
the Integration whose name sorts last, which might not be the default.

A `gh` tool configuration in a WorkstationConfig of your own can replace the Integrations' `gh`
configuration. Which one wins depends on your WorkstationConfig's priority, compared with the -100
that every Integration's generated configuration has.
[Layer merge order](https://docs.ringleader.dev/workstations/configuration/configuration-layers/#layer-merge-order)
explains priorities.

- Above -100, your WorkstationConfig wins. Leaving `priority` out puts it above -100, whether you
  attach it by label or list it in the workstation's `spec.configs`. `gh` then sends your
  configuration's token and no placeholder, so Ringleader treats its requests like any other request
  with no placeholder.
- Below -100, the Integrations win.
- At exactly -100, a WorkstationConfig you list in the workstation's `spec.configs` loses. One
  attached by label wins only when its name sorts after the `GeneratedConfig` name of every
  Integration that writes a `gh` configuration. `rl integration describe` shows that name.

To be sure which identity `gh` uses for a command, set `GH_TOKEN` to its placeholder, as step 3 of
[Choose an identity for a request](#choose-an-identity-for-a-request) shows.

## Troubleshoot

- If a `git clone` with a placeholder in its URL runs as your default identity, check
  `git --version` on the workstation. `git` older than 2.46, such as the 2.43 that Ubuntu 24.04
  ships, sends no credential until GitHub asks for one. Ringleader adds the default's token first,
  so GitHub never asks. Use `git` 2.46 or later, or use `gh` or `curl` with the placeholder. Setting
  `default: false` on every GitHub Integration also works, because GitHub then asks and `git` sends
  the URL's placeholder, but a `git clone` with no placeholder then has no token at all.
- If the same happens on a cloud workstation with `git` 2.46 or later, the edge instance that serves
  the workstation may run a Ringleader version older than placeholders. An edge instance that old
  adds the default's token whatever the request carries, so `gh` and `curl` with the placeholder
  also run as your default identity. `rl integration describe my-github-bot` then says under
  **Credential injection** that the placeholder entry is not honored. Ringleader updates the edge
  instance for you. If the Edge has
  [maintenance windows](https://docs.ringleader.dev/reference/resources/edge/#maintenance-windows), the update
  can wait for the next one.
- If the same happens with `git` 2.46 or later, but `curl` with the placeholder, or `gh` with
  `GH_TOKEN` set to it, runs as the bot account, check whether `XDG_CONFIG_HOME` is set in a shell
  on the workstation:

  ```bash
  echo "$XDG_CONFIG_HOME"
  ```

  Ringleader writes the settings that make `git` send the URL's placeholder under `~/.config/git/`.
  If the command prints nothing, the variable is not set and this is not the cause. If it prints a
  folder other than `~/.config`, `git` reads its settings from that folder and skips Ringleader's.
  Choose one fix:

  - Remove the variable, or set it to the full path of `~/.config`, such as `/home/dev/.config`.
    Then open a new shell. The variable comes from an
    [`environment` entry](https://docs.ringleader.dev/workstations/packages-tools-settings/users-environment-system-settings/#environment-variables)
    in the workstation or a WorkstationConfig, or from your own shell startup files. Other programs
    also keep their settings in the folder it names, so once you remove it they look in
    `~/.config` instead.
  - Leave the variable as it is, and use `curl` with the placeholder, or `gh` with `GH_TOKEN` set
    to it, to act as the bot account.
- If a request gets a `403` saying that the credential selector is unknown, its value starts with
  `rlsel-` but names no GitHub Integration that reaches this workstation. The request never reaches
  GitHub. Check the spelling against `rl integration describe`, and check that the workstation
  carries the labels in the Integration's selector.
- If a request with a placeholder runs as your default identity whatever the tool, or GitHub answers
  `401`, on a workstation on your computer with no Edge declared, the workstation's network process
  may be from a Ringleader version older than placeholders. Restart the workstation, which starts
  that process again:

  ```bash
  rl workstation restart my-git-box -n local
  ```

## Next steps

- [Injected credentials](https://docs.ringleader.dev/security/credentials/injected-credentials/) explains how
  Ringleader adds a token outside the workstation, and where it works.
- [Injection fields](https://docs.ringleader.dev/reference/resources/integration/#injection-fields) lists every
  field of a GitHub Integration, `default` included.
- [Connect workstations to GitHub with the Ringleader GitHub App](https://docs.ringleader.dev/guides/connect-github-app/)
  gets a short-lived token from a GitHub App, in place of a personal access token.

