How to Create Multiple SFTP User in VPS


Are you managing your own VPS? Do you host multiple site on a single VPS? Then you may create multiple FTP (File Transfer Protocol) users to upload files for multiple sites. This guide is how to create multiple SFTP user for VPS. SFTP is secure FTP.

You need to follow these steps after remote login to your VPS using root user (or a user having sudo permission) credential.

1. create a user.

sudo adduser --no-create-home anthony

you will be prompted to set a password as well as few other information.

2. Create a group

addgroup --system filetransfer

3. Add user to the group

usermod -G filetransfer anthony

4. Define which path to access

sudo mkdir /var/www/html/anthony
sudo chown root:root /var/www/html/anthony
chmod 755 /var/www/html/anthony
sudo usermod -d /var/www/html/anthony anthony

5. Limit access to this path

cd /var/www/html/anthony
sudo chown anthony:filetransfer *

6. Configure ssh

sudo nano /etc/ssh/sshd_config

a) Modify Subsystem sftp

Change from:

Subsystem sftp /usr/lib/openssh/sftp-server

Modify to:

Subsystem sftp internal-sftp

b) Add the following code at the end of file

Match Group filetransfer
ChrootDirectory %h
X11Forwarding no
AllowTcpForwarding no
ForceCommand internal-sftp

7. Restart ssh service

sudo service ssh restart

Now, you can access the specified path using FileZilla with the following credential.

Host: sftp://website.com
Username: anthony
Password: password
Port: 22

Hope it helps. If you have any better suggestion you are most welcome.


Leave a Reply

Your email address will not be published. Required fields are marked *