OpenSSH – SFTP – SSH – CHRoot / Jail a user

Just a few usefull commands to help keep a user in a chrooted / jail directory, preventing them from viewing any directory outside of their set jail / chrooted environment. Very useful in a shared hosting system with sftp / ssh enabled

edit the SSH Config
/etc/ssh/sshd_config

# SFTP and SSH Access
Match User YOURUSERNAME
# ChrootDirectory /var/www/vhosts/USERSDOMAINĀ  # Only use if you wish to restrict user to this directory
X11Forwarding no
AllowTcpForwarding no
# ForceCommand /usr/libexec/openssh/sftp-server
# ForceCommand internal-sftp

# Just SFTP Access
Match User YOURUSERNAME
# ChrootDirectory /var/www/vhosts/HOMEDIR # Only use if you wish to restrict user to this directory
X11Forwarding no
AllowTcpForwarding no
ForceCommand internal-sftp

Restart the SSH server
/etc/init.d/sshd restart

Print Friendly, PDF & Email

More Like This


Categories


CentOS Linux Security Security Ubuntu / Mint Web Hosting
  • Post a comment