How to set default permissions for SFTP on VPS

MooseLucifer

Well-known member
Registered
Joined
May 20, 2016
Messages
149
Points
28
Normally, when uploading files to a VPS via SFTP (port 22), for files work normally, we have to set permissions for the folder that contains the files. To save your time on this job, you can set the default permissions for SFTP, it is very simple, we just need to edit SFTP configuration file.

Code:
nano /etc/ssh/sshd_config
On Centos Server

Find:

Code:
Subsystem sftp	/usr/libexec/openssh/sftp-server
Change to:

Code:
Subsystem sftp	/usr/libexec/openssh/sftp-server -u 0002
On Ubuntu & Debian Server

Find:

Code:
Subsystem sftp /usr/lib/openssh/sftp-server
Change to:

Code:
Subsystem sftp /bin/sh -c 'umask 0002; exec /usr/libexec/openssh/sftp-server'
Once the editing is complete, press Ctrl + x and select Y to save the changes. You need to restart sshd to take effect:

Code:
sudo /etc/init.d/vsftpd restart
From now on, when you upload files via SFTP to VPS, will be set folder default permissions is 775, and the files will be set to 644 permissions.

Good luck!
 

PallaviG

New member
Joined
Jul 27, 2016
Messages
10
Points
3
Edit file .bashrc
Add the following at the end of the file:
umask 022
This will correct the problem with the files permissions (644 for files and 755 for folders).
 
Latest Threads
Replies
0
Views
19
Replies
1
Views
37
Replies
0
Views
226
Replies
1
Views
48
Recommended Threads
Replies
3
Views
4,551
Replies
16
Views
9,805
Replies
5
Views
2,026

Latest Hosting OffersNew Reviews

Sponsors

Tag Cloud

You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an alternative browser.

Top