# Is there a way to set root password and add users from the host for a jail that is not running



## Snurg (Dec 9, 2017)

You know, after jail creation it is good to change its root password and occasionally add the one or other user.
(i.e. basically the steps listed in the 'Configuring the Jail' section of `jail(8)` manpage)

Is there a way to perform these things _from the host, without the need to start or invoke the jail?_
(For example, like one can install pkgs on the jail using `pkg -j` on jails not running)

If this is not possible: Neither the `jail(8)` nor the `jexec(8)` manpage say anything about the return value.
_Does always the return value of the process spawned in the jail get returned to the  jail/ jexec caller?_


----------



## masteroman (Dec 9, 2017)

You could try editing shadow file within the jail directly. From host system you can edit any file on the system, so it is matter of basically locating /etc/shadow file for the jail and changing it directly. 

I believe there are no negative side-effect for doing this.


----------



## tobik@ (Dec 9, 2017)

Snurg said:


> Is there a way to perform these things _from the host, without the need to start or invoke the jail?_
> (For example, like one can install pkgs on the jail using  pkg -j on jails not running)


`chroot /path/to/jail/root pw ...`

(or potentially `pw -R /path/to/jail/root ...`)


----------



## Snurg (Dec 9, 2017)

Hm thanks masteroman, you made me look in the right direction.
`vipw(8)` does have a `-d` option to set the working directory so one can handle the jail's password file using it.
`pw(8)` has a `-V` option which seems to work similar.
But probably using chroot as indicated by tobik@ is safer...
Will have to do some manpage study to understand more.

Thank you all!


----------

