Why is umask ignored when uploading files over sftp?

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
1
down vote

favorite
1












Have a wierd issue with permissions on files uploaded to a remote system.



Locally, the file index2.html is chmod 664:



acoder@acoder-local ~ $ ll index2.html
-rw-rw-r-- 1 acoder acoder 29 May 17 14:46 index2.html


After uploading this same file to the remote system, the permissions on the remote directory show:



-rw-r--r--. 1 acoder acoder 3657 May 17 14:43 index2.html


I first thought I had incorrect umask setting on the remote system, but...



[acoder@remote public_html]$ umask
0002


For comparison, if I touch a file on the remote system, the correct permissions (for the given umask) show:



-rw-rw-r--. 1 acoder acoder 0 May 17 14:44 index3.html


So, how are permissions set on files uploaded via sftp? Why is umask ignored when placing files over sftp?







share|improve this question



















  • What umask are you specifying with the -u option of the server? Does it support -u?
    – ajeh
    May 17 at 21:35










  • I don't follow. Are you saying I should pass a separate umask with the sftp options?
    – a coder
    May 18 at 2:49










  • Where is your umask set? In the shell startup files? I can't remember if sftp is started through the shell on the server, but even if it is, it's a non-interactive shell, and your shell probably doesn't read the usual startup files in that case. So any changes to umask there won't be visible to the sftp server
    – ilkkachu
    May 18 at 6:09







  • 2




    @ilkkachu SFTP does not go through the login shell at all (unlike anything else using SSH).
    – Gilles
    May 18 at 11:41














up vote
1
down vote

favorite
1












Have a wierd issue with permissions on files uploaded to a remote system.



Locally, the file index2.html is chmod 664:



acoder@acoder-local ~ $ ll index2.html
-rw-rw-r-- 1 acoder acoder 29 May 17 14:46 index2.html


After uploading this same file to the remote system, the permissions on the remote directory show:



-rw-r--r--. 1 acoder acoder 3657 May 17 14:43 index2.html


I first thought I had incorrect umask setting on the remote system, but...



[acoder@remote public_html]$ umask
0002


For comparison, if I touch a file on the remote system, the correct permissions (for the given umask) show:



-rw-rw-r--. 1 acoder acoder 0 May 17 14:44 index3.html


So, how are permissions set on files uploaded via sftp? Why is umask ignored when placing files over sftp?







share|improve this question



















  • What umask are you specifying with the -u option of the server? Does it support -u?
    – ajeh
    May 17 at 21:35










  • I don't follow. Are you saying I should pass a separate umask with the sftp options?
    – a coder
    May 18 at 2:49










  • Where is your umask set? In the shell startup files? I can't remember if sftp is started through the shell on the server, but even if it is, it's a non-interactive shell, and your shell probably doesn't read the usual startup files in that case. So any changes to umask there won't be visible to the sftp server
    – ilkkachu
    May 18 at 6:09







  • 2




    @ilkkachu SFTP does not go through the login shell at all (unlike anything else using SSH).
    – Gilles
    May 18 at 11:41












up vote
1
down vote

favorite
1









up vote
1
down vote

favorite
1






1





Have a wierd issue with permissions on files uploaded to a remote system.



Locally, the file index2.html is chmod 664:



acoder@acoder-local ~ $ ll index2.html
-rw-rw-r-- 1 acoder acoder 29 May 17 14:46 index2.html


After uploading this same file to the remote system, the permissions on the remote directory show:



-rw-r--r--. 1 acoder acoder 3657 May 17 14:43 index2.html


I first thought I had incorrect umask setting on the remote system, but...



[acoder@remote public_html]$ umask
0002


For comparison, if I touch a file on the remote system, the correct permissions (for the given umask) show:



-rw-rw-r--. 1 acoder acoder 0 May 17 14:44 index3.html


So, how are permissions set on files uploaded via sftp? Why is umask ignored when placing files over sftp?







share|improve this question











Have a wierd issue with permissions on files uploaded to a remote system.



Locally, the file index2.html is chmod 664:



acoder@acoder-local ~ $ ll index2.html
-rw-rw-r-- 1 acoder acoder 29 May 17 14:46 index2.html


After uploading this same file to the remote system, the permissions on the remote directory show:



-rw-r--r--. 1 acoder acoder 3657 May 17 14:43 index2.html


I first thought I had incorrect umask setting on the remote system, but...



[acoder@remote public_html]$ umask
0002


For comparison, if I touch a file on the remote system, the correct permissions (for the given umask) show:



-rw-rw-r--. 1 acoder acoder 0 May 17 14:44 index3.html


So, how are permissions set on files uploaded via sftp? Why is umask ignored when placing files over sftp?









share|improve this question










share|improve this question




share|improve this question









asked May 17 at 18:57









a coder

91962346




91962346











  • What umask are you specifying with the -u option of the server? Does it support -u?
    – ajeh
    May 17 at 21:35










  • I don't follow. Are you saying I should pass a separate umask with the sftp options?
    – a coder
    May 18 at 2:49










  • Where is your umask set? In the shell startup files? I can't remember if sftp is started through the shell on the server, but even if it is, it's a non-interactive shell, and your shell probably doesn't read the usual startup files in that case. So any changes to umask there won't be visible to the sftp server
    – ilkkachu
    May 18 at 6:09







  • 2




    @ilkkachu SFTP does not go through the login shell at all (unlike anything else using SSH).
    – Gilles
    May 18 at 11:41
















  • What umask are you specifying with the -u option of the server? Does it support -u?
    – ajeh
    May 17 at 21:35










  • I don't follow. Are you saying I should pass a separate umask with the sftp options?
    – a coder
    May 18 at 2:49










  • Where is your umask set? In the shell startup files? I can't remember if sftp is started through the shell on the server, but even if it is, it's a non-interactive shell, and your shell probably doesn't read the usual startup files in that case. So any changes to umask there won't be visible to the sftp server
    – ilkkachu
    May 18 at 6:09







  • 2




    @ilkkachu SFTP does not go through the login shell at all (unlike anything else using SSH).
    – Gilles
    May 18 at 11:41















What umask are you specifying with the -u option of the server? Does it support -u?
– ajeh
May 17 at 21:35




What umask are you specifying with the -u option of the server? Does it support -u?
– ajeh
May 17 at 21:35












I don't follow. Are you saying I should pass a separate umask with the sftp options?
– a coder
May 18 at 2:49




I don't follow. Are you saying I should pass a separate umask with the sftp options?
– a coder
May 18 at 2:49












Where is your umask set? In the shell startup files? I can't remember if sftp is started through the shell on the server, but even if it is, it's a non-interactive shell, and your shell probably doesn't read the usual startup files in that case. So any changes to umask there won't be visible to the sftp server
– ilkkachu
May 18 at 6:09





Where is your umask set? In the shell startup files? I can't remember if sftp is started through the shell on the server, but even if it is, it's a non-interactive shell, and your shell probably doesn't read the usual startup files in that case. So any changes to umask there won't be visible to the sftp server
– ilkkachu
May 18 at 6:09





2




2




@ilkkachu SFTP does not go through the login shell at all (unlike anything else using SSH).
– Gilles
May 18 at 11:41




@ilkkachu SFTP does not go through the login shell at all (unlike anything else using SSH).
– Gilles
May 18 at 11:41










1 Answer
1






active

oldest

votes

















up vote
2
down vote













SFTP does not go through a login shell at all. It's directly managed by the SSH server. If the umask you expect is set by /etc/profile, ~/.profile, ~/.bashrc or some other shell initialization file then it doesn't apply to SFTP.



You can set an umask through the PAM module pam_umask. The setting for the SSH server will apply to both SSH shell sessions (unless overridden by a shell initialization file) and SFTP sessions.



You can also set the umask for SSH specifically by editing the Subsystem sftp line of /etc/sshd_config to pass the -u option to sftp-server.






share|improve this answer





















  • I tried changing /etc/login.defs UMASK value to 002, but no luck - same permissions as before (detailed in question).
    – a coder
    May 18 at 14:00










  • Also tried editing /etc/ssh/sshd_config with Subsystem sftp internal-sftp -u 0022, restarted sshd service, still same permissions issue.
    – a coder
    May 18 at 14:06










Your Answer







StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "106"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
convertImagesToLinks: false,
noModals: false,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);








 

draft saved


draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f444454%2fwhy-is-umask-ignored-when-uploading-files-over-sftp%23new-answer', 'question_page');

);

Post as a guest






























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes








up vote
2
down vote













SFTP does not go through a login shell at all. It's directly managed by the SSH server. If the umask you expect is set by /etc/profile, ~/.profile, ~/.bashrc or some other shell initialization file then it doesn't apply to SFTP.



You can set an umask through the PAM module pam_umask. The setting for the SSH server will apply to both SSH shell sessions (unless overridden by a shell initialization file) and SFTP sessions.



You can also set the umask for SSH specifically by editing the Subsystem sftp line of /etc/sshd_config to pass the -u option to sftp-server.






share|improve this answer





















  • I tried changing /etc/login.defs UMASK value to 002, but no luck - same permissions as before (detailed in question).
    – a coder
    May 18 at 14:00










  • Also tried editing /etc/ssh/sshd_config with Subsystem sftp internal-sftp -u 0022, restarted sshd service, still same permissions issue.
    – a coder
    May 18 at 14:06














up vote
2
down vote













SFTP does not go through a login shell at all. It's directly managed by the SSH server. If the umask you expect is set by /etc/profile, ~/.profile, ~/.bashrc or some other shell initialization file then it doesn't apply to SFTP.



You can set an umask through the PAM module pam_umask. The setting for the SSH server will apply to both SSH shell sessions (unless overridden by a shell initialization file) and SFTP sessions.



You can also set the umask for SSH specifically by editing the Subsystem sftp line of /etc/sshd_config to pass the -u option to sftp-server.






share|improve this answer





















  • I tried changing /etc/login.defs UMASK value to 002, but no luck - same permissions as before (detailed in question).
    – a coder
    May 18 at 14:00










  • Also tried editing /etc/ssh/sshd_config with Subsystem sftp internal-sftp -u 0022, restarted sshd service, still same permissions issue.
    – a coder
    May 18 at 14:06












up vote
2
down vote










up vote
2
down vote









SFTP does not go through a login shell at all. It's directly managed by the SSH server. If the umask you expect is set by /etc/profile, ~/.profile, ~/.bashrc or some other shell initialization file then it doesn't apply to SFTP.



You can set an umask through the PAM module pam_umask. The setting for the SSH server will apply to both SSH shell sessions (unless overridden by a shell initialization file) and SFTP sessions.



You can also set the umask for SSH specifically by editing the Subsystem sftp line of /etc/sshd_config to pass the -u option to sftp-server.






share|improve this answer













SFTP does not go through a login shell at all. It's directly managed by the SSH server. If the umask you expect is set by /etc/profile, ~/.profile, ~/.bashrc or some other shell initialization file then it doesn't apply to SFTP.



You can set an umask through the PAM module pam_umask. The setting for the SSH server will apply to both SSH shell sessions (unless overridden by a shell initialization file) and SFTP sessions.



You can also set the umask for SSH specifically by editing the Subsystem sftp line of /etc/sshd_config to pass the -u option to sftp-server.







share|improve this answer













share|improve this answer



share|improve this answer











answered May 18 at 11:50









Gilles

503k1189951522




503k1189951522











  • I tried changing /etc/login.defs UMASK value to 002, but no luck - same permissions as before (detailed in question).
    – a coder
    May 18 at 14:00










  • Also tried editing /etc/ssh/sshd_config with Subsystem sftp internal-sftp -u 0022, restarted sshd service, still same permissions issue.
    – a coder
    May 18 at 14:06
















  • I tried changing /etc/login.defs UMASK value to 002, but no luck - same permissions as before (detailed in question).
    – a coder
    May 18 at 14:00










  • Also tried editing /etc/ssh/sshd_config with Subsystem sftp internal-sftp -u 0022, restarted sshd service, still same permissions issue.
    – a coder
    May 18 at 14:06















I tried changing /etc/login.defs UMASK value to 002, but no luck - same permissions as before (detailed in question).
– a coder
May 18 at 14:00




I tried changing /etc/login.defs UMASK value to 002, but no luck - same permissions as before (detailed in question).
– a coder
May 18 at 14:00












Also tried editing /etc/ssh/sshd_config with Subsystem sftp internal-sftp -u 0022, restarted sshd service, still same permissions issue.
– a coder
May 18 at 14:06




Also tried editing /etc/ssh/sshd_config with Subsystem sftp internal-sftp -u 0022, restarted sshd service, still same permissions issue.
– a coder
May 18 at 14:06












 

draft saved


draft discarded


























 


draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f444454%2fwhy-is-umask-ignored-when-uploading-files-over-sftp%23new-answer', 'question_page');

);

Post as a guest













































































Popular posts from this blog

How to check contact read email or not when send email to Individual?

Displaying single band from multi-band raster using QGIS

How many registers does an x86_64 CPU actually have?