# chroot jail FreeBSD "su: who are you?"



## Dr_Death_UAE (May 27, 2009)

Hello, i create chroot jail every thing fine but when i try to login with the jailed user with su i got:


> su: who are you?



from the logs:



> May 27 15:33:28 h4x0r sudo:      r0x : TTY=ttyp0 ; PWD=/ ; USER=root ; COMMAND=/usr/sbin/chroot /home/jail /usr/bin/su - r0x



from visudo:


> r0x       ALL=NOPASSWD: /usr/sbin/chroot, /usr/bin/su - r0x



from "/home/jail/etc/passwd":


> r0x:*:1003:1003:User &:/home/r0x:/usr/local/bin/bash



from "/etc/passwd":


> r0x:*:1003:1003:User &:/home/jail/home/r0x:/bin/chroot-shell



the "chroot-shell" include:


> #!/usr/bin/env sh
> /usr/local/bin/sudo /usr/sbin/chroot /home/jail /usr/bin/su - $USER "$@"



i use the same methods with linux systems it work fine, i use pwd_mkdb to update the master.passwd on the jail:


> pwd_mkdb -d /home/jail/etc/ /home/jail/etc/master.passwd


but still the same. i read that i need to use rssh as the shell instead of bash shell.


----------



## vivek (May 27, 2009)

You can login to jail using jexec if openssh not installed in a jail:

```
jls -v
jexec jailid csh
```

If openssh installed and normal user account created make sure that account is a part of wheel group. Again login using jexec and create user account using pw. Once done start openssh so that user can login into the account and use su -


----------



## SirDice (May 27, 2009)

chroot != jail

So which one is it? A chrooted or a jailed environment?

Please see jail(8) and chroot(8) for the differences.


----------



## vivek (May 27, 2009)

OP: yes this is confusing as pointed out by SirDice. Please clarify... on freebsd there is no need to use chroot call. chroot(2) can be escaped easily; use jails.


----------



## Dr_Death_UAE (May 27, 2009)

Hello, it is chroot.


----------

