How to chroot ssh user using Jailkit

Jailkit is a set of utilities to limit user accounts to specific files using chroot() and or specific commands. Jailkit is known to be used in network security appliances from several leading IT security firms, internet servers from several large enterprise organizations, internet servers from internet service providers, as well as many smaller companies and private users that need to secure cvs, sftp, shell or daemon processes. Jailkit is very useful for jailing applications and users that should (or need) to be isolated from the rest of the system (and from each other). The jail folder has a replication of the directory structure of a normal Linux box. The difference is that you only copy in the bare minimum of what you need into the directory structure. jailkit-ssh  

1. Install the jailkit

Download, compile & install the jailkit :

$ sudo apt-get install checkinstall && wget http://olivier.sessink.nl/jailkit/jailkit-2.17.tar.gz $ tar -zxvf jailkit-2.17.tar.gz $ cd jailkit-2.17 $ ./configure $ make $ sudo checkinstall && dpkg -i jailkit_2.17-1_amd64.deb

2. Setting up the jail chroot

sudo mkdir /var/www/example.com && sudo chown root. /var/www/example.com
Create the environment (i give my user git power – if you don’t want to, just remove the git):
$ jk_init -v /var/www/example.com basicshell editors extendedshellnetutils ssh sftp jk_lsh git
Create & jail the user :
$ sudo adduser user-1 $ sudo jk_jailuser -m -j /var/www/example.com
Make sure the /etc/passwd for user-1 is :
user-1:x:1001:1001::/var/www/example.com/./home/user-1:/usr/sbin/jk_chrootsh

Create home folder & add your ssh public key 
 
$ sudo mkdir -p /var/www/example.com/home/user-1/.ssh<br />$ chown -R user-1./var/www/example.com/home/user-1<br />$ vim/var/www/example.com/home/user-1/.ssh/authorized_keys
 
The common problem with jailkit when user is cannot login can be see in this post.