File transfer Protocol
Linux Ubuntu

How to Setup User for SFTP with Limited access in Ubuntu

This blog explain how to setup user for SFTP with limited access in Ubuntu.

  • User can only limited to some dir (folder) with was allocated by admin remember this is for Ubuntu

Create a new user:

sudo useradd -d /home/yoursite.com client_user

Create a password for new user:

sudo passwd client_user

Restrict Access:

%h is home dir

subsystem sftp internal-sftp

Match User client_user

ChrootDirectory %h

AllowTCPForwarding no

X11Forwarding no

ForceCommand internal-sftp

sudo service ssh restart

ERROR “fatal: bad ownership or modes for chroot directory’ 

we need to make sure that the home directory of a user is owned by root and no one else can write into that directory. So change the owner of home directory using the following commands:

sudo chown root:root /home/yoursite.com

sudo chmod 755 /home/yoursite.com

So this is how to Setup User for SFTP with Limited access in Ubuntu. If you have any other query comment below.

Leave a Reply

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