# Jenkins: Home Profile

When Jenkins is installed on a linux host, the Jenkins service and any spawned builds run under the context of the jenkins user account.  
Problem is, the jenkins user account is not a regular user account, with a profile that lives under /home.  
Instead, the Jenkins user profile is located at: /var/lib/jenkins  
This irregularity creates some nuances for several scenarios that assume a normal user profile location, such as:

- Managing SSH keys
- Nuget caching
- NPM caching

The above scenarios, and others, point to the /home folder as where a user profile lives.

So, you will come across many tutorials for installing nuget, or standing up NPM caches, etc, that are all required things for a capable Jenkins build server to have and use.

But, following these instructions will require special care as to what user account will need them, and if they are properly mapped.

There's a couple of ways to find where the jenkins user profile is located.  
But since the jenkins user is a system account, without a defined shell, we can't simply login as it and check it's HOME environment variable.

So, the next best thing is to use what Linux uses for storing the home path.  
We inspect /etc/passwd.

Opening /etc/passwd and looking for the jenkins user line, shows this:

[![image.png](https://wiki.galaxydump.com/uploads/images/gallery/2025-02/scaled-1680-/3vl3RXhcNpYFhQpP-image.png)](https://wiki.galaxydump.com/uploads/images/gallery/2025-02/3vl3RXhcNpYFhQpP-image.png)

We say to use the above technique, because you can't readily login as the jenkins user and run: ECHO <span class="hljs-variable">$HOME  
This is because t</span><span class="hljs-variable">he jenkins account is more like a service account, and has no defined shell.  
Plus, we don't easily know what the jenkins password is.</span>

### <span class="hljs-variable">Solution</span>

See this page for details of how to execute commands as a system account: [Linux: Impersonating Users](https://wiki.galaxydump.com/link/111)

Or, better. Follow the steps on this page to assign a shell and add a profile file to the jenkins system account: [Ubuntu: Converting a System Account to Interactive](https://wiki.galaxydump.com/link/120)  
Doing so, allows your Jenkins build server to run software packages that are normally installed on a per-user basis, such as NVM and NPM.

### Examples

We don't yet have a list of things that have to be done with the Jenkins user account.  
But, here are some examples, to illustrate the referenced solution:

##### Installing SSH Keys

```bash
sudo -u jenkins mkdir -p /var/lib/jenkins/.ssh
sudo -u jenkins chmod 700 /var/lib/jenkins/.ssh
sudo -u jenkins ssh-keygen -t rsa -b 4096 -f /var/lib/jenkins/.ssh/id_rsa
```

##### Configuring Git for a Jenkins User

```bash
sudo -u jenkins git config --global user.name "Jenkins CI"
sudo -u jenkins git config --global user.email "jenkins@example.com"
```

##### Getting Environment Variables for a User

```bash
sudo -u jenkins env
```

<div class="contain-inline-size rounded-md border-[0.5px] border-token-border-medium relative bg-token-sidebar-surface-primary dark:bg-gray-950" id="bkmrk--1"></div>