Last active
March 11, 2022 15:44
-
-
Save SeyedMostafaAhmadi/7faf82c552722e71232670be7a9cf23a to your computer and use it in GitHub Desktop.
How to Restrict SFTP Users to Home Directories Using chroot Jail
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Create Group and User | |
groupadd your-groupname | |
adduser your-username --shell /sbin/nologin | |
# add your-username to your-groupname | |
usermod -aG your-groupname your-username | |
# Modify SSH Configuration File in /etc/ssh/sshd_config | |
Subsystem sftp internal-sftp | |
Match Group your-groupname | |
ChrootDirectory /specific-directory ### Owner This directory have be root | |
ForceCommand internal-sftp | |
X11Forwarding no | |
AllowTcpForwarding no | |
# Restart your ssh server | |
systemctl restart sshd | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment