In this entry we will perform a caged SFTP configuration in which it will be mounted via BIND on another route.
User and directory configuration
We create the group
text
groupadd sftpWe create the user and add it to the sftp group
text
useradd -g sftp -s /bin/false -d /home/usersftp/ usersftpWe assign a password to the user
text
passwd usersftpWe create the folder structure and assign the corresponding permissions
Bash
mkdir -p /home/usersftp/public/
chown root:root /home/usersftp/
chown usersftp:sftp /home/usersftp/public/We create the directory where we are going to mount the file system using bind
Bash
mkdir -p /var/www/html/sftpWe add the fstab file to the following line and mount the file system
Bash
echo ‘ /var/www/html/sftp /home/usersftp/public/ none bind 0 0’ >> /etc/fstab
mount /home/usersftp/public/SSH Configuration
We access /etc/ssh/sshd_config and we must modify the following line:
text
Subsystem sftp /usr/lib/openssh/sftp-serverFor this:
text
Subsystem sftp internal-sftpWe also have to add the following configuration to the end of the file:
text
Match user usersftp
ChrootDirectory %h
X11Forwarding no
AllowTcpForwarding no
ForceCommand internal-sftp
KbdInteractiveAuthentication yesWe restart the ssh service
Bash
service sshd restartAll the best.
:wq!
Comments