Written by James McDonald

July 25, 2022

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

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

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

Match Group sftptest
        ChrootDirectory /sftp/%u
        ForceCommand internal-sftp
# 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

Submit a Comment

Your email address will not be published.

You May Also Like…

CakePHP4 Tutorial Videos

So I have been using CakePHP since 2015 and have now started to try and solidify my learning by making Youtube Videos....