Request an invite
Docs menu
View as Markdown

Keep tokens out of your machines

Give a machine an API token or password that stays in your Mac's Keychain.

Add a credential

Requires OSMates Pro.

The machine holds a placeholder, such as osm_k3x9.... OSMates swaps it for the value only on HTTPS requests to the hosts you choose.

  1. In the library sidebar, select Credentials.
  2. Click Add Credential in the toolbar.
  3. Enter a Name, such as gh.
  4. Enter the Host, such as api.github.com, and choose how it's Sent As.
  5. Enter a Variable, such as GH_TOKEN.
  6. Type the token in Value, then click Add.

A host is an exact name, without wildcards. To change a credential later, double-click it. To add one in Terminal, pipe the value in:

sh
printf %s "$GITHUB_TOKEN" | osmates credential add gh --header Authorization --prefix "Bearer " --host api.github.com --variable GH_TOKEN

Grant a credential to a machine

Requires OSMates Pro.

  1. In Credentials, select the credential and click Grant.
  2. Choose the Machine and how long it Lasts, then click Grant.

Credentials listing gh with its hosts and placeholder variable, granted to two machines until a date or until the machine stopsCredentials listing gh with its hosts and placeholder variable, granted to two machines until a date or until the machine stops

A grant lasts 24 hours by default. To grant for 8 hours in Terminal:

sh
osmates credential grant gh dev --for 8h

The machine's network access must allow each of the credential's hosts. On Apple Virtualization, the machine also needs Allowed Destinations Only, then a restart if it started Open.

With Open access, a program using HTTP/3 or its own DNS over HTTPS bypasses OSMates.

A clone keeps a grant only with Clones Keep It. Agent sandboxes never get one.

Use a credential in the machine

Programs started with osmates vm exec, osmates run, vm_exec, or vm_run get the placeholder in the credential's variable:

sh
osmates vm exec dev -- sh -c 'curl -s -H "Authorization: Bearer $GH_TOKEN" https://api.github.com/user'

For a program you start yourself, Control-click the machine under the credential and choose Copy Placeholder.

OSMates swaps the placeholder only in the header, Basic password, or query parameter the credential uses. Anywhere else, such as a request body, it goes through unchanged. Responses from a granted host arrive uncompressed. Programs that pin a certificate or need HTTP/2 or HTTP/3 fail on that host.

Agents see placeholders in vm_info, but no MCP tool adds, grants, or reads a credential.

Trust the OSMates authority

On granted hosts the machine sees an OSMates certificate. Windows and Linux trust its authority by themselves.

macOS needs an administrator. With someone at the machine's screen, click Ask an Administrator to Trust It in the machine's Agents settings.

Programs with their own trust list need the authority's file:

System File
Linux /etc/osmates/authority.pem
Windows C:\ProgramData\OSMates\authority.pem
macOS /Library/Application Support/OSMates/authority.pem

vm exec and run set NODE_EXTRA_CA_CERTS to it. Point other tools at it yourself, such as REQUESTS_CA_BUNDLE for Python requests.

Revoke and remove a credential

Removing a credential revokes every grant, then deletes its value from your Keychain, which you can't undo.

  1. In Credentials, select the machine under the credential and click Revoke.
  2. To remove the credential, select it and choose Credential > Remove in the toolbar.

To revoke and remove in Terminal:

sh
osmates credential revoke gh dev
osmates credential remove gh

The machine's next request gets 403. Once no credential is granted there, click Remove the Authority in its Agents settings.

Report a problem with this page