Setting up SFTP with chroot

0 0
0 0

Instead of installing with VSFTPD package to configure the FTP service we can use the default SSH service and port 22 for secure file system protocol. This will secure the file transfer with added encrypted method which used in default SSH configuration.

first, add a group

# groupadd secure_ftp

Add the user to newly created Group

Note: User will not be added in Sudo, Don’t try with current user which you have logged in if so you will loose the admin privileges

# usermod -G secure_ftp sysadmin

Edit the ssh configuration

# vim /etc/ssh/sshd_config

Comment the following line to add a new line below that

#Subsystem sftp /usr/lib/openssh/sftp-server

Add this line below the Subsystem.

# Subsystem sftp internal-sftp

Append the below chroot config.

Match Group secure_ftp
x11Forwarding no
AllowTcpForwarding no
ChrootDirectory /home
ForceCommand internal-sftp

Restart the ssh service

# sudo service ssh restart

Now login from client machines

# sftp sysadmin@

This will work using default ssh with the port (22).

About Author

Babin Lonston

Overall 14+ Years of experience in the IT field, currently working as a Senior Linux administration with Virtualization & Cloud. Being numismatist for a long time.
0 0 %
0 0 %
0 0 %
0 0 %
0 0 %
0 0 %

Leave a Comment

Subscribe To Our Newsletter

Join our mailing list to receive the latest news and updates from our team.

We promise not to spam you, and we don't usually send more than one email a week.

You have Successfully Subscribed!

Exit mobile version