top of page
  • Bankim Bhagat

Create SFTP server with Multiple users accessing a Single directory

Updated: Jun 23



To upgrade existing packages, run the following command. This does not install any new packages.

sudo apt update

Next install openssl-server. It is not installed by default on ubuntu desktop edition.

sudo apt install openssh-server

Create a shared FTP directory

sudo mkdir /path/to/sftp_shared

Set the permission to this folder

sudo chown root:sftp_users /path/to/sftp_shared
sudo chmod 770 /path/to/sftp_shared

Add a new user

sudo adduser --shell /usr/bin/nologin --ingroup sftp_users --home /path/to/sftp_shared/<username> --disabled-password <username>

OR

sudo adduser --shell /bin/false sftpuser

OR

sudo adduser <username>

Create a new group

addgroup sftp_users

Add users to a this group

sudo usermod -aG sftp_users <username>

Modify the SSH config. Open the ssd_config file in nano text editor

sudo nano /etc/ssh/sshd_config

Add the following lines to the bottom of the file

# Enable SFTP subsystem
Subsystem sftp internal-sftp

# Match block for SFTP users
Match Group sftp_users
    ChrootDirectory /path/to/sftp_shared
    ForceCommand internal-sftp
    X11Forwarding no
    AllowTcpForwarding no

Now restart the ssh service for changes to take effect

sudo service ssh restart

Troubleshooting

sudo tail -f /var/log/auth.log | grep sftp


Tip: ChrootDirectory

Specifies the pathname of a directory to chroot(2) to after authentication. All components of the pathname must be root-owned directories that are not writable by any other user or group. After the chroot, sshd(8) changes the working directory to the user's home directory.

50 views0 comments

Recent Posts

See All

Here is a comparison of the Logitech B100 Optical Mouse, HP Wired Mouse 100, and Dell MS116 Wired Optical Mouse: As you can see, the HP Wired Mouse 100 has the highest DPI of the three mice, making it

bottom of page