Appearance

Language

Mastering AI agents

How to Separate GitHub Access for Multiple Projects on One Oracle Server in 2026: Isolating Claude Code Remote Control

When one server runs Claude Code for several projects, here is how to keep each project limited to its own GitHub repo: one Linux user per project, choosing between a fine-grained token, a deploy key and a GitHub App, rotation, rulesets that block direct pushes to main, and what to revoke if the server is compromised.

Kelvin Wang · · 12 min read

Key points

  1. Git worktrees do not isolate permissions; separate Linux users and private home directories keep projects from sharing the same tokens and keys.
  2. Give each project its own Linux user with a 700 home directory and no sudo, its own Claude sign-in and its own GitHub credential limited to one repo.
  3. Human review needs rulesets that require PRs and approvals; you can't approve a PR opened with your own token.
  4. If the server is compromised, delete tokens and deploy keys on GitHub and check the security log; gh auth logout on the server does not revoke anything.

I got an Oracle Cloud A1 instance in Tokyo and use systemd to keep Claude Code Remote Control running, with a fine-grained token for GitHub. Before adding a second or third project, there’s another question to settle: which GitHub repos should each project’s sessions be able to reach?

The user isolation, credential setup, and revocation steps below come from official documentation and have not been tested on this server. The usernames and paths in the commands are examples, not a verified server configuration.

Which credentials can a Claude Code session on the server reach?

A Remote Control session runs on your server; file access and command execution stay on that machine 1. Without additional isolation, assess which credentials it can reach using the permissions of the Linux user running it:

  • The GitHub CLI sign-in. When gh finds no system credential store, it writes the token to a plain text file 2. Run gh auth status on the server to see where yours is stored.
  • SSH private keys. ~/.ssh may contain deploy keys or personal keys. GitHub’s docs note that deploy keys usually have no passphrase, making them easy to take from a compromised server 3.
  • The Claude sign-in. On Linux it defaults to ~/.claude/.credentials.json with mode 0600. If CLAUDE_CONFIG_DIR is set, the file lives under that directory instead 4. Mode 0600 keeps other users out; it does nothing against processes running as the same user.
  • Environment variables. A token in GH_TOKEN is just as visible to that user’s processes.

A personal access token acts as you, limited by both your account’s access and the token’s permissions 5 10. Those permissions determine how much damage a session could do if it makes a mistake, follows an injected prompt, or gets compromised. --spawn=worktree separates working directories but does not isolate permissions. The approach below uses a separate Linux user for each project 22; containers and virtual machines are other isolation options 23.

How do you give each project its own Linux user?

Run these steps from the admin account that has sudo (ubuntu on Oracle’s Ubuntu image), replacing proj-a with your project’s name.

  1. Create the user without a password. --disabled-password sets no password but doesn’t block other login methods such as SSH keys 6. This user never needs to log in from outside; you switch to it from the admin account:

    sudo adduser --disabled-password --comment "" proj-a
  2. Set the home directory to 700. DIR_MODE in adduser.conf decides the mode of new home directories 7, but your system’s config may have been changed, so set it explicitly and check. Look at the admin account’s home directory too:

    sudo chmod 700 /home/proj-a
    ls -ld /home/*
  3. Make sure it has no sudo. A user that can gain root access through sudo can bypass other users’ file permissions. This command should show no permitted sudo commands for the project user:

    sudo -l -U proj-a
  4. Enable linger. The user’s systemd manager then starts at boot and keeps running after logout, so services run without anyone logged in 8:

    sudo loginctl enable-linger proj-a
  5. Switch over and set up each user separately. As this user, install Claude Code per the official instructions, run claude once to sign in and trust the project folder, then set up this project’s own GitHub credential (the next sections cover which kind):

    sudo -iu proj-a

Keep the admin account for server maintenance and run project sessions under their own users, without the admin account’s privileges.

How do you manage another user’s Remote Control service with systemd?

Put the unit file in that user’s own ~/.config/systemd/user/, for example /home/proj-a/.config/systemd/user/claude-proj-a.service. When adapting the single-project unit, point WorkingDirectory to a repo owned by this user. Use %h/.local/bin/claude as the executable in ExecStart, followed by remote-control --name "a1 - proj-a" --spawn=worktree. The service also needs to load this project’s credential, as described next.

You don’t have to switch users to enable or inspect it. systemctl’s --machine option connects to a given user’s service manager, and leaving out the host after user@ means the local machine 9. From the admin account:

sudo systemctl --user -M proj-a@ daemon-reload
sudo systemctl --user -M proj-a@ enable --now claude-proj-a.service
sudo systemctl --user -M proj-a@ status claude-proj-a.service

Repeat for each project: one user, one service, one Claude sign-in and one set of GitHub credentials per project.

Fine-grained token, deploy key or GitHub App: which one per project?

All three can be limited to one repo. They differ in whether they can use the API, whether they expire, and what you lose if the server is compromised.

CredentialScopeWhat it can doWhat it can't doExpiry
Fine-grained personal access tokenSelected repos of one owner; always read access to all public reposgit push, plus the API permissions you grant, such as opening PRsActs as you, so PRs it opens are yours and you can't approve themChosen at creation; organization or enterprise policies may limit the lifetime
Deploy keyOne repo only; the same key can't be reused on another repogit clone; git push if write access is allowedCall the REST API, so it can't open PRsNever expires
GitHub App installation tokenRepos the app is installed on, narrowed further when generatedgit push and the app's API permissions; actions are attributed to the appNeeds code that trades the app's private key for tokens; the most setup1 hour

The details come from GitHub’s docs on personal access tokens 10, REST API authentication 5, deploy keys 3 and installation tokens 11 12. One way to choose:

  • Push only, no API: a deploy key. It authenticates SSH Git access, not REST API requests. A session with only this key cannot use the API to open or merge a PR. The trade-off is that it never expires, so rotation is on you.
  • Sessions open their own PRs: a fine-grained token. Under Repository access pick only this repo, set Contents and Pull requests to Read and write, and add no other permissions. Leave Administration off in particular: its write permission can create, change, and delete rulesets and add deploy keys 13.
  • Short-lived tokens and PRs you approve: a GitHub App. Installation tokens expire after an hour, and PRs are authored by the app, so you can approve them. Anyone holding the app’s private key can keep minting new tokens 14, though. Token expiry does not protect you once that key is stolen.

Check whether a fine-grained token supports your situation before choosing it. It currently does not support repositories where you are an outside collaborator or repository collaborator. Organizations can also block these tokens or require approval; a pending token can only read public resources 10. For someone else’s project, check your role in the repo first.

GitHub Apps need one more check. Restricting a token to one repo limits that token, not the private key used to create it. A process holding the key can request tokens for the app’s other installations. Without a repo restriction, a new token gets access to every repo allowed for that installation 12. To keep projects separate, give each project user only its restricted token. If it must hold a private key, the app’s entire installation scope must belong to that project. An external service that holds the key must also restrict which repos each project can request.

For fine-grained tokens, use the GitHub CLI’s recommended GH_TOKEN approach. Avoid mixing stored sign-ins with environment tokens: GH_TOKEN takes precedence over stored credentials 2 24:

  1. Store the token in a private file owned by the project user. For example, create ~/.config/claude-github.env containing one line, GH_TOKEN=YOUR_PROJECT_TOKEN. Give the file mode 0600 and keep it out of the repo.
  2. Load it into the service. Add EnvironmentFile=%h/.config/claude-github.env under [Service] in the unit, then reload and restart the service. systemd builds the service environment from its manager and unit settings. Running export GH_TOKEN=… in an interactive shell does not mean a service started at boot receives it 25.
  3. Configure credentials for HTTPS Git. As the project user, run gh auth setup-git --hostname github.com --force to make gh the credential helper 26. The repo’s remote must use an HTTPS URL without a token, such as https://github.com/OWNER/REPO.git. This does not switch an SSH remote to token authentication 27.

The service’s gh and HTTPS Git commands then use its token. An interactive shell that hasn’t loaded the token has a separate environment. Mode 0600 keeps other users from reading the file; it does not hide the token from this project’s own sessions. An app installation token can also be supplied as an HTTPS password through a credential helper, but it needs refreshing when it expires. Keep tokens out of remote URLs 11. Deploy keys use SSH remotes 3.

How often should you rotate tokens and keys?

  • Always give fine-grained tokens an expiry date. GitHub recommends one; an expired token stops working and can’t be restored, only replaced 15. Organization or enterprise policies may also limit its lifetime 10.
  • Put deploy keys on your own schedule. They have no expiry date and stay active even if the person who added them loses access to the repo 3. To rotate, generate a new key on the server, add it to the repo, confirm a push works, then delete the old one.
  • Add a new app private key before deleting the old one. An app can have up to 25 private keys, and with only one you must generate a new key before you can delete it 14.
  • The Claude sign-in expires too. Within three days of expiry, Claude Code warns at startup and asks you to run /login. Once the sign-in expires and cannot be refreshed, model requests fail until you sign in again 4. For always-on services, schedule a regular sign-in check under each user.
  • Delete tokens you no longer use. GitHub removes personal access tokens unused for a year 10, but don’t wait for that.

How do you stop anyone pushing directly to main?

Tokens and deploy keys decide which repo a session can touch, not whether it can change main directly. That’s the job of repository rulesets. Private repos need GitHub Pro, Team or Enterprise Cloud for rulesets; public repos get them on the free plan 16.

  1. Create a branch ruleset. In the repo, go to Settings, Rules, Rulesets, New ruleset, New branch ruleset 17.
  2. Activate it. Change Enforcement status to Active. The default is Disabled, which does nothing.
  3. Choose the protected branch. Under Target branches, add the default branch.
  4. Require a PR. Tick Require a pull request before merging, so changes to the target branch must be associated with a PR 18.
  5. Block force pushes and deletion. Check that Block force pushes and Restrict deletions are ticked; both are on by default 18.
  6. Leave no bypass identities. Keep the Bypass list empty so the rules apply to everyone.

This blocks updates to main that have no associated PR. Require a pull request does not require approval, and it does not ban every direct push: a merge commit associated with an existing PR may still be pushed through Git if it satisfies the rules 18. The merge API uses Contents write permission 13, so a session with permission to open and merge PRs can still do both itself.

For human review, set the required approval count and enable Dismiss stale pull request approvals when new commits are pushed. That prevents new changes from relying on an earlier approval 18. A PR’s author cannot approve their own PR 19, which affects your choice of credential:

  • With a deploy key, the session can push branches but cannot use the key to call the API to open or merge PRs. You can handle those steps yourself. Enforcing human approval still takes an approval rule; the key type alone does not provide it.
  • With your fine-grained token, you are the PR author, so requiring approvals blocks you too. If you are the only reviewer, Require a pull request alone preserves the PR workflow but does not guarantee human review.
  • With a GitHub App, the app is the author and you can approve, which is the best fit for required approvals.

What do you revoke if the server is compromised?

If you suspect the server is compromised, assume every user’s credentials on it have been copied. Running gh auth logout on the server only removes the local config and doesn’t revoke the token 20, so every step below happens on GitHub and claude.ai.

  1. Delete the fine-grained tokens. Settings, Developer settings, Personal access tokens, Fine-grained tokens, then Delete for each project’s token 10.
  2. Remove the deploy keys. In each repo’s Settings, Deploy keys, delete the keys this server used.
  3. Replace the GitHub App private key. If the key was on the server, generate a new one in the app’s settings and delete the old one 14; installation tokens already issued expire within an hour 11.
  4. Read the security log. Profile picture, Settings, then Security log under Archives lists the last 90 days of account activity. Fine-grained tokens and SSH keys have their own categories, and you can filter and export to JSON or CSV 21.
  5. Check the repos. Look for branches, PRs and commits you don’t recognise, confirm the rulesets are still active and nobody was added to the Bypass list.
  6. Deal with the Claude sign-ins. If you use Trusted Devices, remove old devices under Trusted devices in claude.ai account settings; removal revokes the device credential immediately 1. This does not establish that a copied CLI sign-in has also been revoked. The cited docs do not confirm a complete revocation procedure for a personal account. Run /login for each user on the new server, but do not treat a fresh sign-in as proof that the old credential is invalid.

FAQ

Isn’t one Linux user per project too much work?

With one project, or several that share the same permissions anyway, one user is enough. When projects belong to different people or different GitHub owners, or one repo matters much more than the rest, it’s worth separating them. The extra work is installing and signing in to Claude Code once per user; services can all be managed from the admin account with systemctl --user -M as shown above.

Don’t git worktrees already keep projects apart?

Worktrees separate working directories and branches, not permissions. Under one user, sessions in every worktree read the same ~/.config/gh and ~/.ssh.

If a fine-grained token uses Only select repositories, can it reach other repos?

The token cannot access private repos you did not select, but it always has read access to all public repos 10. It also belongs to a single owner. Your own repos and those of an organization you belong to need separate tokens, subject to the organization policies and role restrictions described above.

Go deeper How to Get an Oracle Cloud Free ARM Instance in 2026: Claude Code 24/7 and a Git Repo Workflow Getting the A1 instance, running Remote Control with systemd, and connecting it to GitHub.

Sources

  1. 1. Remote Control · Claude Code Docs · checked 2026-11-13
  2. 2. gh auth login · GitHub CLI Manual · checked 2026-11-13
  3. 3. Managing deploy keys · GitHub Docs · checked 2026-11-13
  4. 4. Authentication · Claude Code Docs · checked 2026-11-13
  5. 5. Authenticating to the REST API · GitHub Docs · checked 2026-11-13
  6. 6. adduser(8) · Ubuntu Manpages (noble) · checked 2026-11-13
  7. 7. adduser.conf(5) · Ubuntu Manpages (noble) · checked 2026-11-13
  8. 8. loginctl · systemd · checked 2026-11-13
  9. 9. systemctl · systemd · checked 2026-11-13
  10. 10. Managing your personal access tokens · GitHub Docs · checked 2026-11-13
  11. 11. Authenticating as a GitHub App installation · GitHub Docs · checked 2026-11-13
  12. 12. Generating an installation access token for a GitHub App · GitHub Docs · checked 2026-11-13
  13. 13. Permissions required for fine-grained personal access tokens · GitHub Docs · checked 2026-11-13
  14. 14. Managing private keys for GitHub Apps · GitHub Docs · checked 2026-11-13
  15. 15. Token expiration and revocation · GitHub Docs · checked 2026-11-13
  16. 16. About rulesets · GitHub Docs · checked 2026-11-13
  17. 17. Creating rulesets for a repository · GitHub Docs · checked 2026-11-13
  18. 18. Available rules for rulesets · GitHub Docs · checked 2026-11-13
  19. 19. Approving a pull request with required reviews · GitHub Docs · checked 2026-11-13
  20. 20. gh auth logout · GitHub CLI Manual · checked 2026-11-13
  21. 21. Reviewing your security log · GitHub Docs · checked 2026-11-13
  22. 22. Running multiple Claude Code Remote Controls on one host: Linux users, systemd and git worktree (Chinese) · Jason Finance · 2026-10-12
  23. 23. Sandboxing · Claude Code Docs · checked 2026-11-13
  24. 24. gh environment · GitHub CLI Manual · checked 2026-11-13
  25. 25. systemd.exec(5) · Ubuntu Manpages (noble) · checked 2026-11-13
  26. 26. gh auth setup-git · GitHub CLI Manual · checked 2026-11-13
  27. 27. gitcredentials · Git · checked 2026-11-13

About the author

Kelvin Wang

Electrical engineer building tools with AI agents, sharing hands-on notes on engineering and investing.

More about me