Set File Permissions on Uploaded Files
When you upload a file to the server using either sftp or scp, the file permissions of the uploaded file can depend on both the server configuration and the source file permissions.
If the file already exists on the server:
If the file does not exist on the server, the following factors affect the permissions set on the transferred file. Items lower on this list override items higher on the list.
Note: UMASK is included by default in the list of environment variables allowed by SettableEnvironmentVars. If UMASK is not included in this list, you cannot modify UMASK values using an environment file on the server or using the client SetRemoteEnv keyword.
To set permissions on uploaded files on the server using the environment file
To set permissions on uploaded files from the client using SetRemoteEnv
The following session shows the use of SetRemoteEnv to set permissions on a file uploaded using scp. The source file (demo) allows user, group, and world read/write access (644) on the client (abchost). After the upload, the file allows user-only read/write access (600) on the server (xyzhost).
joe@abchost:~> ls -l demo
-rw-r--r-- 1 joe users 30 2008-10-02 12:07 demo
joe@abchost:~> scp -oSetRemoteEnv=UMASK=066 demo firstname.lastname@example.org:
demo 30 0.0KB/s 00:00 100%
joe@abchost:~> ssh email@example.com
Last login: Thu Oct 2 16:56:22 2008 from 184.108.40.206
[joe@xyzhost ~]$ ls -l demo
-rw------- 1 joe joe 30 Oct 2 16:57 demo