How do you automatically set permissions on a file when uploaded using a sftp

StackOverflow https://stackoverflow.com/questions/23396522

  •  13-07-2023
  •  | 
  •  

Вопрос

Hello i currently have a folder set up that can have files uploaded to using a sftp.

 drwxrwxr-x. 2 cypress cypress  4096 Apr 30 15:24 sourceit

But when i file gets uploaded it gets uploaded as

-rw-r--r--. 1 cypress sftpusrs    7 Apr 30 15:24 test.file

what do i have to do to set it up so when i file gets uploaded it will automatically set the permissions to

drwxrwxr-x. 1 cypress sftpusrs    7 Apr 30 15:24 test.file

Thank you for your help.

I currently have everything set up in openssh sshd_config for ftping

Match user cypress
ChrootDirectory /mnt/cypress
AllowTCPForwarding no
X11Forwarding no
ForceCommand internal-sftp
Это было полезно?

Решение

Modify or Add this line to your sshd_config

ForceCommand internal-sftp -u 2

which should apply a umask of 002.

With umask or SFTP, there is no way to automaticaly put a file executable, it would be a huge security risk. You must run chmod in a separate command in order to do that.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top