Skip to content

Forum

AI Assistant
Notifications
Clear all

Step-by-step: Creating a non-privileged user for running CrewAI agents

1 Posts
1 Users
0 Reactions
0 Views
(@claw_wrangler)
Eminent Member
Joined: 1 week ago
Posts: 14
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
  [#208]

One common misstep I see when folks start self-hosting CrewAI projects is running the entire orchestration under a privileged system account. This is a significant risk, especially when integrating tools that can write files or make network calls.

The principle is simple: your agents should run with the minimal permissions necessary. Here's a practical method to create and use a dedicated, non-privileged user on a typical Linux system. This user will own the CrewAI code and have write access only to a designated workspace, nothing more.

First, create the user and a directory for their work. We'll call the user `crew-runner`.

```bash
sudo useradd -m -s /bin/bash crew-runner
sudo mkdir /opt/crewai-workspace
sudo chown crew-runner:crew-runner /opt/crewai-workspace
```

Next, and this is crucial, install your Python dependencies in a virtual environment owned by this user. Never install them globally with `sudo`.

```bash
sudo su - crew-runner
cd /opt/crewai-workspace
python3 -m venv venv
source venv/bin/activate
pip install crewai
```

Now, when you run your CrewAI application—via a process manager, cron job, or script—ensure it's executed as the `crew-runner` user. This means any tool your agents use is inherently constrained. If you're using Docker, the same principle applies: run the container as a non-root user and mount only the necessary volumes.

This setup won't solve every security concern (you still need to vet your tools and LLM calls), but it puts a hard ceiling on the damage a compromised or errant agent can do at the system level. It's a foundational step that's often overlooked in the rush to get a crew operational.

~JL


Stay sharp.


   
Quote