Rsync on ssh chroot jail

Rsync Chroot Jail

Using OpenSSH you can bind SSH, SFTP, SCP or RSYNC users to their home directory and restrict them to access other directories on the SSH server. In this article we will demonstrate on configuring Rsync on ssh chroot jail secure system environment.


  • How to configure chroot rsync?
  • How to configure chroot rsync on CentOS 7?
  • How to configure chroot rsync on RHEL 7?
  • How to get chroot rsync working in chroot ssh sandbox environment?
  • Rsync on ssh chroot jail
  • Chroot rsync over ssh


Setting up a secure or chroot ssh and rsync environment requires a sandox environment which has its own libraries and binaries. In this article, we’ll bind all ssh and rsync users who are part of chrootssh group into /data/chroot-ssh directory. This article has been tested on CentOS 7 and RHEL 7. You can refer to the steps given in this article to configure chroot ssh and rsync on other Linux distributions.

  1. In order to setup Rsync on ssh chroot jail, configure chroot ssh environment with the help of the following article:

Chroot SSH Configuration on Linux|RHEL|CentOS

  1. After chroot ssh environment setup is completed, execute following set of commands to get rsync command working in chroot ssh sandbox environment.

  1. Remove all contents from /data/chroot-ssh/lib64 directory.
rm -rf /data/chroot-ssh/lib64/*

  1. Mount /lib64 directory at /data/chroot-ssh/lib64 directory with mount bind option.
mount --bind /lib64 /data/chroot-ssh/lib64

# To the make the above mount permanent add the following configuration in /etc/fstab file. 
/lib64         /data/chroot-ssh/lib64         -         defaults,bind       0 0

  1. Copy rsync binary to /data/chroot-ssh/bin/ directory.
cp -p /usr/bin/rsync /data/chroot-ssh/bin/

  1. Create a passwd and group file in /data/chroot-ssh/etc directory and then copy the specific ssh user and group information to passwd and group file in /data/chroot-ssh/etc directory.
# sample chroot ssh user is test ssh and group is chrootssh
cd /data/chroot-ssh/etc
grep chrootssh /etc/group >> group
grep testssh /etc/passwd >> passwd

  1. Now restart sshd service and start rsync file transfer.


Execute the following command for ssh login and rsync file transfer testing.

# Rsync file transfer
$ rsync -avz file1.txt testssh@
testssh@'s password: 
sending incremental file list

sent 99 bytes  received 35 bytes  24.36 bytes/sec
total size is 0  speedup is 0.00

# SSH Login
$ ssh testssh@
testssh@'s password: 
-bash-4.2$ pwd
-bash-4.2$ ls

If you have enjoyed the above article, the following are add on articles related to Rsync on ssh chroot jail:

You May Also Like


About the Author: TekFik

TekFik is a technical blogging site helps techies and engineers to solve their day to day issues and also allows everyone to share knowledge and feedback. Please feel free to contact us at if there is anything.

Leave a Reply

Your email address will not be published. Required fields are marked *