Setup Chroot SFTP in CentOS
First version AT 2018-08-25 09:39:36 Updated AT 2019-11-08 14:36:29 for user separate syslog configuration.
Set up an account that will be used only to transfer files(and not to ssh to the system), you should setup SFTP Chroot Jail as explained in this article.
If you want to give sftp access on your system to outside vendors to transfer files, you should not use standard sftp. Instead, you should setup Chroot SFTP Jail as explained below.
Chroot SFTP Environment
chroot A chroot on Unix operating systems is an operation that changes the apparent root directory for the current running process and its children. Chroot SFTP means that the user can sftp to the system, and view only the directory that you’ve designated to perform sftp.
Setup in CentOS
Test environment at CentOS 6.5.
Create a New Group
groupadd sftpusersCreate Users
useradd -g sftpusers -s /sbin/nologin sftpuser
passwd sftpuser
Setup sftp-server Subsystem in sshd_config
Create sftp Home Directory
Restart sshd and Test Chroot SFTP
service sshd restart
Script for Setup Chroot SFTP in CentOS 6.5
Log internal-sftp chroot jailed users
add to
/etc/ssh/sshd_config
add to
/etc/rsyslog.d/sftp.conf
mkdir for socket file and touch sftp log
restart sshd and rsyslog
Reference
Last updated
Was this helpful?