I am currently working on integrating a client internal system with MessageXchange via an SFTP gateway for EDI with Coles, Woolworth and Metcash (when MessageXchange / Colladium - completes their accreditation)
So for testing I wanted to emulate their SFTP endpoint. So I followed the very useful steps here:
https://www.thegeekstuff.com/2012/03/chroot-sftp-setup/
My Steps on Ubuntu 22.04
Create a root folder for all chroot'd SFTP dirs
1 | mkdir /sftp |
Create a SFTP "home" directory for a specific user and some in out dirs to mimic the MessageXchange folder structure and set permissions to allow user to read and write to the directories
1 2 3 4 | mkdir -p /sftp/sftptest/ {IN,OUT} chown sftptest:sftptest -Rv /sftp/sftptest/ * # make sure the SFTP "home" directory is owned by root or you get the Broken pipe error below chown root:root /sftp/sftptest |
Add some configuration to /etc/ssh/sshd_config
1 2 3 | Match Group sftptest ChrootDirectory /sftp/ %u ForceCommand internal- sftp |

1 2 | # restart ssh systemctl restart ssh |
Make sure the SFTP home dir is owned by root
One thing I found was the the chroot'd home directory needs to be owned by root
if the chroot SFTP homedir is owned by the user you will get a Broken pipe
error:

Directory Structure

0 Comments