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.
Run the following command to add a new user and set the password:
adduser developer passwd developer
SH 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!