1. Add 'sftpusers' group:
sudo groupadd sftpusers
2. Create a home directory for 'guestuser' user that will be added at the next step:
sudo mkdir /var/guestuserhomedirAs the result of the above command permissions for /var/guestuserhomedir should be 755 (owner: root, group: root).
3. Create 'guestuser' user, add it to the 'sftpusers' group and set a new password for this user:
sudo useradd -g sftpusers -d /var/guestuserhomedir -s /usr/sbin/nologin guestuser sudo passwd guestuser
4. Create SFTP directories and set permissions (correct permissions are important):
sudo mkdir /var/sftp_upload_dir sudo mkdir /var/sftp_upload_dir/guestuser sudo mkdir /var/sftp_upload_dir/guestuser/incoming sudo chown guestuser:sftpusers /var/sftp_upload_dir/guestuser/incoming sudo chmod 777 /var/sftp_upload_dir/guestuser/incomingAs the result permissions for /var/sftp_upload_dir and /var/sftp_upload_dir/guestuser directories should be 755 (owner: root, group: root), permissions for /var/sftp_upload_dir/guestuser/incoming should be 777 (owner: guestuser, group: sftpusers).
5. Open /etc/ssh/sshd_config file and comment out the following line:
# Subsystem sftp /usr/libexec/openssh/sftp-serverNow add the new line after the commented out line:
Subsystem sftp internal-sftpAdd the following lines at the bottom of the file:
Match group sftpusers ChrootDirectory /var/sftp_upload_dir/%u ForceCommand internal-sftp
6. Restart SSH service:
sudo /etc/init.d/ssh restart
7. Now you can connect to SFTP server using any client of your choice (FileZilla, Midnight Commander), using the username 'guestuser' and password that you have set at step 3. You will have to use the same port as for SSH (22 by default). You will have full access to incoming directory on the server.