chroot to homedir for SSH user


I read to allow SSH access.
This works great, except for the tiny problem that the user has access to the whole server;
Would it be possible to chroot him to the homedir?

I tried to add the following to /etc/ssh/ssh_config:

Match Group dev
ChrootDirectory /home/cavaria

This did not work

I read this:

This ‘trick’ advices you to create a new bin: rbash (cp /bin/bash /bin/rbash)
This will actually disable the cd command. But testing this: I can still read the whole server, list other directories and vim config files.

Still no solution


There’s not a simple fix, unfortunately.

Take a look at the second question here, titled “How can I prevent other types of users from browsing the entire filesystem”:

Hello !

This thread is a bit aged, but I had same problem, what I did was to use chroot, ssh_chroot, sftp and some things, also ldap and bind mounts where used for logfiles.

I made a bunch of scripts to get it work in virtualmin without any hands on, beside basic configuration of virtualmin and webmin.

It took long time to make the scripts, I am not a programmer so it was hundreds of trial and errors to get all logics in place, trying to use virtualmin commands and webmin commands, and the pre post scripts and its environment variables as much as possible to secure for future updates.

And I am not fully there yet, some features is lacking, and some bugs remains, but i got it 95% working as I wanted it.

Now afterwards, a cloudmin setup with better rack servers which has supports for KVM would spend me some headache. But I have time, not money :slight_smile:

I can share the scripts and how I did if someone is interested, the scripts and ways of doing things could be improved by someone with more skills than I have. But to publish the scripts for the public I am not ready to do yet.

All scripts and stuff Centos 6.x on Intel, and AIX/RedHat on Power.

Regarding “chroot” with SSH, I was never able to truly jail the user, so, I moved to Encrypted FTP instead.

I am able to keep them “chrooted” and they only need to change FTP to FTPS in their client config.


Also I search for a solution for this, but it seems that is no integrated solution in Virtualmin / Webmin.
Until now I’ve used (and it seems that I will continue to use) Jailkit. It uses chroot and is not so hard to use.
You can find it at
Use tutorials to install it and configure it.