SFTP
# systemctl enable sshd.service
# systemctl start sshd.service
# systemctl start sshd.service
# vi /etc/ssh/sshd_config
Comment the following line (add a hash before it)
Subsystem sftp /usr/local/libexec/sftp-server
and add the following just below it, I recommend using tab instead of spaces
Subsystem sftp internal-sftp
Now scroll to the end of the config file and add the following to create the match rule:
Match Group sftponly
ChrootDirectory %h
ForceCommand internal-sftp
X11Forwarding no
AllowTcpForwarding no
ChrootDirectory %h
ForceCommand internal-sftp
X11Forwarding no
AllowTcpForwarding no
Save the config file and close it. (Press ESC and type 'wq!')
# systemctl restart sshd.service
# groupadd sftponly
# useradd john -g sftponly -s /bin/false
# passwd john
# useradd john -g sftponly -s /bin/false
# passwd john
# mkdir /home/john/datadir
# chown root /home/john
# chmod 755 /home/john
# chown john /home/john/datadir
# chmod 755 /home/john/datadir
# chown root /home/john
# chmod 755 /home/john
# chown john /home/john/datadir
# chmod 755 /home/john/datadir
# setsebool -P ssh_chroot_rw_homedirs on
https://community.spiceworks.com/how_to/112551-setup-a-sftp-server-running-on-centos-linux-7
Comments
Post a Comment