skip to Main Content
Add A SFTP User To CentOS

How can you add a sFTP user to CentOS? Here in this post we go through the command needed to realize this on a Vultr CentOS VPS.

Add User

Run the following command to add a new user and set the password:

adduser developer
passwd developer

SSH Config Change

Do a  nano /etc/ssh/sshd_config. Then scroll to the very bottom of the file and append the following configuration snippet /etc/ssh/sshd_config:
. . .

Match User developer
 ForceCommand internal-sftp
 PasswordAuthentication yes
 ChrootDirectory /var/sftp
 # PermitTunnel no
 AllowAgentForwarding no
 AllowTcpForwarding no
 X11Forwarding no

Update: On CentOS the sshd daemon refused to restart due to line PermitTunnel no. Caused the error PermitTunnel is not allowed within a match block. Without it SFTP nor SSH was possible so this whole block has been commented out until further notice.

Add User to Group Nginx

After that do a :

 usermod -a -G nginx developer

to add the user to the group nginx. Then restart the ssh server:  /etc/init.d/sshd start

NB If you are running Apache then the current owner and group are likely apache.

CHMOD and CHOWN Tweaks

Then change the owner of /var/www/html/* to developer (or username of your choice) using

chown -R developer:nginx html/

and then make sure new files added get these permission using:

chmod 2755 html/

After that you are good to go!

Jasper Frumau

Jasper has been working with web frameworks and applications such as Laravel, Magento and his favorite CMS WordPress including Roots Trellis and Sage for more than a decade. He helps customers with web design and online marketing. Services provided are web design, ecommerce, SEO, content marketing. When Jasper is not coding, marketing a website, reading about the web or dreaming the internet of things he plays with his son, travels or run a few blocks.

Leave a Reply

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

Back To Top