Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

After many trials and errors trying to setup a working sftp server for multiple groups with chrooted directory I decided to share what finally worked for me. I am a novice 2 months into Ubuntu so please don't shot me yet :) This is nothing new but I had a hard time finding a complete article that explains how can a novice like me could achieve it.

Sudo vi /etc/ssh/sshd_config

and add

Subsystem sftp internal-sftp
Match group Group-A
    ChrootDirectory /Group-A
    ForceCommand internal-sftp
    AllowTcpForwarding no

Match group Broup-B
    ChrootDirectory /Group-B
    ForceCommand internal-sftp
    AllowTcpForwarding no

save and exit and start creating the users and group directories:

sudo useradd Group-A-Users
sudo useradd Group-B-Users
sudo passwd Username
sudo usermod -G Group-A Group-A-Users= All users that belong to this group
sudo usermod -G Group-B Group-B-Users= All users that belong to this group
sudo mkdir /Group-A
sudo mkdir /Group-B
sudo mkdir /Group-A/Upload
sudo mkdir /Group-B/Upload

Now lets set permission to the directories. The main folder must be own by root and no one should have write access to it by any other user or group or it will result in ssh crashing after restart.

sudo chown root /Group-A
sudo chown root /Group-B
sudo chmod go-w /Group-A
sudo chmod go-w /Group-B
sudo chgrp GroupName /Group-A/Upload
sudo chgrp GroupName /Broup-B/Upload
sudo chmod ug+rwX /Group-A/Upload
sudo chmod ug+rwX /Group-B/Upload

This is a guide for dummy's users like me who are new to Ubuntu and want to setup a secure sftp server for work or friends.

share|improve this question
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.