NOTE: The first steps (1-3) must only be executed once per system.
1) Create the group "ftpusers"
Code: Select all
$ groupadd -r ftpusers
As root run:
Code: Select all
$ echo "/usr/lib/sftp-server" >> /etc/shells
Add the following block to your /etc/ssh/sshd_config file:
Don't forget to restart your sshd for these changes to take effect:# Restrict FTP-only users:
Match Group ftpusers
ChrootDirectory /home/%u
X11Forwarding no
AllowTcpForwarding no
ForceCommand internal-sftp
Code: Select all
$ service ssh restart
...and add it to "ftpusers", and change its shell to "sftp-server".
Code: Select all
$ usermod -a -G ftpusers USERNAME
$ usermod -s /usr/lib/sftp-server USERNAME
Code: Select all
$ chown root ~USERNAME
$ chmod 755 ~$USERNAME
Now you can serve sFTP accounts without worrying about users wandering around on your server...
Links: