Skip to content

Forum

AI Assistant
Notifications
Clear all

Walkthrough: Isolating Aider's git operations to a separate, limited user account.

2 Posts
2 Users
0 Reactions
3 Views
(@practical_threat_bob)
Eminent Member
Joined: 1 week ago
Posts: 19
Topic starter
Translate
English
Spanish
French
German
Italian
Portuguese
Russian
Chinese
Japanese
Korean
Arabic
Hindi
Dutch
Polish
Turkish
Vietnamese
Thai
Swedish
Danish
Finnish
Norwegian
Czech
Hungarian
Romanian
Greek
Hebrew
Indonesian
Malay
Ukrainian
Bulgarian
Croatian
Slovak
Slovenian
Serbian
Lithuanian
Latvian
Estonian
  [#928]

Hey everyone. I'm setting up Aider on my homelab and I'm worried about its default git permissions. It runs as my main user, so if the AI agent gets tricked, it could `git push --force` or worse, right? 😅

I want to isolate its git operations to a separate, limited account. Here's my plan—can you guys check if I'm missing something?

1. Created a new system user `aider-git` with no login shell and home directory.
```bash
sudo useradd -r -s /bin/false -m -d /var/lib/aider-git aider-git
```

2. I'll run the Aider container itself as my user, but I'm thinking of binding a directory (like `/home/bob/aider-workspace`) to the container and setting its ownership to `aider-git`. Then, inside the container, run the git commands as that user via `sudo` or `runuser`.

Is this the right approach? Specifically:
- How do I handle SSH keys for this limited user? A dedicated key pair with only push/pull permissions to the repos it needs?
- Should I use `git config --global --add safe.directory` in the `aider-git` context?

Looking for concrete config examples, not just theory. Thanks!

-- Bob


Still learning.


   
Quote
(@junior_dev_zoey)
Active Member
Joined: 1 week ago
Posts: 16
Translate
English
Spanish
French
German
Italian
Portuguese
Russian
Chinese
Japanese
Korean
Arabic
Hindi
Dutch
Polish
Turkish
Vietnamese
Thai
Swedish
Danish
Finnish
Norwegian
Czech
Hungarian
Romanian
Greek
Hebrew
Indonesian
Malay
Ukrainian
Bulgarian
Croatian
Slovak
Slovenian
Serbian
Lithuanian
Latvian
Estonian
 

Oh yeah, SSH keys. I'm doing something similar. For the key, yeah, make a new pair just for `aider-git`.

I set mine up with a forced command in `~aider-git/.ssh/authorized_keys`. Something like:

```
command="git-shell -c "$SSH_ORIGINAL_COMMAND"",no-port-forwarding,no-X11-forwarding,no-agent-forwarding,no-pty ssh-rsa AA...
```

That locks it down to *only* git commands. Then on your git server (like Gitea or GitLab), you give that key read/write only to the specific repos it needs. No admin stuff.

What git hosting are you using? I had to fiddle with the config a bit for GitHub.



   
ReplyQuote