# Create home directory for nagios user



## i.am.the.problem (Wednesday at 11:10 AM)

I'm setting up Nagios and want to configure some check_by_ssh commands.
To allow password less login I need to create a public/private key for the nagios user.
The nagios user was created by the nagios4 port without a home directory.

```
#  getent passwd nagios
nagios:*:181:181:Nagios pseudo-user:/var/spool/nagios:/usr/sbin/nologin
```
How can I create a home directory for the nagios user?


----------



## sko (Wednesday at 11:44 AM)

`pw usermod <user> -d <homedir>`

For zabbix user I usually use a subdirectory in the config directory (/usr/local/etc/zabbix/). This way backing up the config also includes all local scripts in that directory. Should work the same way with nagios, but its completely up to your preferences - if you want all home directories under /usr/home, just create one there...


----------



## i.am.the.problem (Wednesday at 11:53 AM)

sko said:


> `pw <user> -d <homedir>`
> 
> For zabbix user I usually use a subdirectory in the config directory (/usr/local/etc/zabbix/). This way backing up the config also includes all local scripts in that directory. Should work the same way with nagios, but its completely up to your preferences - if you want all home directories under /usr/home, just create one there...


Sounds like a good idea. I used the following command.

```
pw moduser nagios -d /usr/local/etc/nagios
```


----------



## SirDice (Wednesday at 12:57 PM)

Note that the nagios user has /usr/sbin/nologin set as its shell, which means you can't login with that account. So you may also want to set the shell to /bin/sh. Although you would only need to do this if you want to login from a remote machine to this one.


----------



## sko (Wednesday at 1:28 PM)

i.am.the.problem said:


> Sounds like a good idea. I used the following command.
> 
> ```
> pw moduser nagios -d /usr/local/etc/nagios
> ```



sorry, of course it should have been "pw usermod" - I've fixed that in my original post.


----------

