SFTP chroot - EasyEngine/easyengine GitHub Wiki
EasyEngine (ee)
Setup User/Group:
Setup User:
^_^[[email protected]:~]# adduser user
Adding user `user' ...
Adding new group `user' (1002) ...
Adding new user `user' (1002) with group `user' ...
Creating home directory `/home/user' ...
Copying files from `/etc/skel' ...
Enter new UNIX password:
Retype new UNIX password:
passwd: password updated successfully
Changing the user information for user
Enter the new value, or press ENTER for the default
Full Name []: user
Room Number []:
Work Phone []:
Home Phone []:
Other []:
Is the information correct? [Y/n] Y
Change User Shell
^_^[[email protected]:~]# chsh -s /usr/sbin/nologin user
Setup Group:
^_^[[email protected]:~]# usermod -G www-data user
^_^[[email protected]:~]# id user
uid=1002(user) gid=1002(user) groups=1002(user),33(www-data)
Setup Permission:
^_^[[email protected]:~]# chown root:root /home/
^_^[[email protected]:~]# chown root:root /home/user
^_^[[email protected]:~]# chmod g+s /var/www/example.com/htdocs/wp-content/themes
^_^[[email protected]:~]# chmod 775 /var/www/example.com/htdocs/wp-content/themes
Setup Chroot Directory:
^_^[[email protected]:~]# mkdir -p /home/user/themes
^_^[[email protected]:~]# mount --bind /var/www/example.com/htdocs/wp-content/themes /home/user/themes
NOTE: After system reboot, above mount point is removed, you have to add above command in your /etc/rc.local
file.
Setup SFTP Chroot:
^_^[[email protected]:~]# vim /etc/ssh/sshd_config +/Subsystem
#Subsystem sftp /usr/lib/openssh/sftp-server
Subsystem sftp internal-sftp
# Appened following code at EOF
Match group user
X11Forwarding no
ChrootDirectory %h
AllowTcpForwarding no
ForceCommand internal-sftp
Restart SSH Service
^_^[[email protected]:~]# service ssh restart
ssh stop/waiting
ssh start/running, process 31242