How to get sftp to respect my umask setting

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












1














I'm trying to get sftp to give me a umask of 002 but it keeps behaving like the umask is 022. How do I get it to do that?



Red Hat 7.4



/etc/ssh/sshd_config has the line:



Subsystem sftp internal-sftp -u 002


I've also tried



Subsystem sftp internal-sftp -u 0002


After each change I make to sshd_config I issue the following command:



sudo systemctl restart sshd.service


Then in a separate window I log into sftp.



Once I've uploaded the file in sftp, then "ls -Fla" in the shell session returns:



drwxrwsr-x. 2 [myID] [myGroup] 32 Dec 28 17:37 ./
drwxrwxr-x. 4 [siteID] [siteGroup] 50 Dec 26 18:44 ../
-rw-r--r--. 1 [myID] [myGroup] 9173334 Dec 28 17:37 [myUploadedFile]


(last line having r-- as the group permission)



where I would expect:



drwxrwsr-x. 2 [myID] [myGroup] 32 Dec 28 17:37 ./
drwxrwxr-x. 4 [siteID] [siteGroup] 50 Dec 26 18:44 ../
-rw-rw-r--. 1 [myID] [myGroup] 9173334 Dec 28 17:37 [myUploadedFile]


(last line having rw- as the group permission)



I've also tried



Subsystem sftp internal-sftp -u ug=rwx


but that one causes sftp to close the connection.
At least it confirms that I'm updating the right configuration file.










share|improve this question





















  • Are you sure the remote umask is the problem? Your SFTP client may be setting explicit permissions on the remote file.
    – Kenster
    Dec 29 '18 at 19:09















1














I'm trying to get sftp to give me a umask of 002 but it keeps behaving like the umask is 022. How do I get it to do that?



Red Hat 7.4



/etc/ssh/sshd_config has the line:



Subsystem sftp internal-sftp -u 002


I've also tried



Subsystem sftp internal-sftp -u 0002


After each change I make to sshd_config I issue the following command:



sudo systemctl restart sshd.service


Then in a separate window I log into sftp.



Once I've uploaded the file in sftp, then "ls -Fla" in the shell session returns:



drwxrwsr-x. 2 [myID] [myGroup] 32 Dec 28 17:37 ./
drwxrwxr-x. 4 [siteID] [siteGroup] 50 Dec 26 18:44 ../
-rw-r--r--. 1 [myID] [myGroup] 9173334 Dec 28 17:37 [myUploadedFile]


(last line having r-- as the group permission)



where I would expect:



drwxrwsr-x. 2 [myID] [myGroup] 32 Dec 28 17:37 ./
drwxrwxr-x. 4 [siteID] [siteGroup] 50 Dec 26 18:44 ../
-rw-rw-r--. 1 [myID] [myGroup] 9173334 Dec 28 17:37 [myUploadedFile]


(last line having rw- as the group permission)



I've also tried



Subsystem sftp internal-sftp -u ug=rwx


but that one causes sftp to close the connection.
At least it confirms that I'm updating the right configuration file.










share|improve this question





















  • Are you sure the remote umask is the problem? Your SFTP client may be setting explicit permissions on the remote file.
    – Kenster
    Dec 29 '18 at 19:09













1












1








1







I'm trying to get sftp to give me a umask of 002 but it keeps behaving like the umask is 022. How do I get it to do that?



Red Hat 7.4



/etc/ssh/sshd_config has the line:



Subsystem sftp internal-sftp -u 002


I've also tried



Subsystem sftp internal-sftp -u 0002


After each change I make to sshd_config I issue the following command:



sudo systemctl restart sshd.service


Then in a separate window I log into sftp.



Once I've uploaded the file in sftp, then "ls -Fla" in the shell session returns:



drwxrwsr-x. 2 [myID] [myGroup] 32 Dec 28 17:37 ./
drwxrwxr-x. 4 [siteID] [siteGroup] 50 Dec 26 18:44 ../
-rw-r--r--. 1 [myID] [myGroup] 9173334 Dec 28 17:37 [myUploadedFile]


(last line having r-- as the group permission)



where I would expect:



drwxrwsr-x. 2 [myID] [myGroup] 32 Dec 28 17:37 ./
drwxrwxr-x. 4 [siteID] [siteGroup] 50 Dec 26 18:44 ../
-rw-rw-r--. 1 [myID] [myGroup] 9173334 Dec 28 17:37 [myUploadedFile]


(last line having rw- as the group permission)



I've also tried



Subsystem sftp internal-sftp -u ug=rwx


but that one causes sftp to close the connection.
At least it confirms that I'm updating the right configuration file.










share|improve this question













I'm trying to get sftp to give me a umask of 002 but it keeps behaving like the umask is 022. How do I get it to do that?



Red Hat 7.4



/etc/ssh/sshd_config has the line:



Subsystem sftp internal-sftp -u 002


I've also tried



Subsystem sftp internal-sftp -u 0002


After each change I make to sshd_config I issue the following command:



sudo systemctl restart sshd.service


Then in a separate window I log into sftp.



Once I've uploaded the file in sftp, then "ls -Fla" in the shell session returns:



drwxrwsr-x. 2 [myID] [myGroup] 32 Dec 28 17:37 ./
drwxrwxr-x. 4 [siteID] [siteGroup] 50 Dec 26 18:44 ../
-rw-r--r--. 1 [myID] [myGroup] 9173334 Dec 28 17:37 [myUploadedFile]


(last line having r-- as the group permission)



where I would expect:



drwxrwsr-x. 2 [myID] [myGroup] 32 Dec 28 17:37 ./
drwxrwxr-x. 4 [siteID] [siteGroup] 50 Dec 26 18:44 ../
-rw-rw-r--. 1 [myID] [myGroup] 9173334 Dec 28 17:37 [myUploadedFile]


(last line having rw- as the group permission)



I've also tried



Subsystem sftp internal-sftp -u ug=rwx


but that one causes sftp to close the connection.
At least it confirms that I'm updating the right configuration file.







sftp umask






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Dec 29 '18 at 1:47









Charles BelovCharles Belov

61




61











  • Are you sure the remote umask is the problem? Your SFTP client may be setting explicit permissions on the remote file.
    – Kenster
    Dec 29 '18 at 19:09
















  • Are you sure the remote umask is the problem? Your SFTP client may be setting explicit permissions on the remote file.
    – Kenster
    Dec 29 '18 at 19:09















Are you sure the remote umask is the problem? Your SFTP client may be setting explicit permissions on the remote file.
– Kenster
Dec 29 '18 at 19:09




Are you sure the remote umask is the problem? Your SFTP client may be setting explicit permissions on the remote file.
– Kenster
Dec 29 '18 at 19:09










2 Answers
2






active

oldest

votes


















2














Notice that umask values only reduce permissions, never adds them.



So if your local file was permission 0644 (-rw-r--r--) then the umask will not add a group write flag. The umask will remove "other write"; so if your local file was 0666 then the remote would be 0664.



If you want to ensure the remote file has group write then you might want the -m 664 flag instead.






share|improve this answer




















  • Confirmed, thank you. Solved!
    – Charles Belov
    Jan 5 at 4:44


















0














In your sshd config file, try setting "ForceCommand" on your groups



Match Group GROUP_NAME
ForceCommand internal-sftp -u 0002


Restart your sshd process for the new settings to take effect






share|improve this answer




















  • Do you have some reason to believe the normal subsystem configuration isn't working here?
    – Kenster
    Dec 29 '18 at 19:10










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',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
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%2f491404%2fhow-to-get-sftp-to-respect-my-umask-setting%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























2 Answers
2






active

oldest

votes








2 Answers
2






active

oldest

votes









active

oldest

votes






active

oldest

votes









2














Notice that umask values only reduce permissions, never adds them.



So if your local file was permission 0644 (-rw-r--r--) then the umask will not add a group write flag. The umask will remove "other write"; so if your local file was 0666 then the remote would be 0664.



If you want to ensure the remote file has group write then you might want the -m 664 flag instead.






share|improve this answer




















  • Confirmed, thank you. Solved!
    – Charles Belov
    Jan 5 at 4:44















2














Notice that umask values only reduce permissions, never adds them.



So if your local file was permission 0644 (-rw-r--r--) then the umask will not add a group write flag. The umask will remove "other write"; so if your local file was 0666 then the remote would be 0664.



If you want to ensure the remote file has group write then you might want the -m 664 flag instead.






share|improve this answer




















  • Confirmed, thank you. Solved!
    – Charles Belov
    Jan 5 at 4:44













2












2








2






Notice that umask values only reduce permissions, never adds them.



So if your local file was permission 0644 (-rw-r--r--) then the umask will not add a group write flag. The umask will remove "other write"; so if your local file was 0666 then the remote would be 0664.



If you want to ensure the remote file has group write then you might want the -m 664 flag instead.






share|improve this answer












Notice that umask values only reduce permissions, never adds them.



So if your local file was permission 0644 (-rw-r--r--) then the umask will not add a group write flag. The umask will remove "other write"; so if your local file was 0666 then the remote would be 0664.



If you want to ensure the remote file has group write then you might want the -m 664 flag instead.







share|improve this answer












share|improve this answer



share|improve this answer










answered Dec 29 '18 at 2:19









Stephen HarrisStephen Harris

25.3k24477




25.3k24477











  • Confirmed, thank you. Solved!
    – Charles Belov
    Jan 5 at 4:44
















  • Confirmed, thank you. Solved!
    – Charles Belov
    Jan 5 at 4:44















Confirmed, thank you. Solved!
– Charles Belov
Jan 5 at 4:44




Confirmed, thank you. Solved!
– Charles Belov
Jan 5 at 4:44













0














In your sshd config file, try setting "ForceCommand" on your groups



Match Group GROUP_NAME
ForceCommand internal-sftp -u 0002


Restart your sshd process for the new settings to take effect






share|improve this answer




















  • Do you have some reason to believe the normal subsystem configuration isn't working here?
    – Kenster
    Dec 29 '18 at 19:10















0














In your sshd config file, try setting "ForceCommand" on your groups



Match Group GROUP_NAME
ForceCommand internal-sftp -u 0002


Restart your sshd process for the new settings to take effect






share|improve this answer




















  • Do you have some reason to believe the normal subsystem configuration isn't working here?
    – Kenster
    Dec 29 '18 at 19:10













0












0








0






In your sshd config file, try setting "ForceCommand" on your groups



Match Group GROUP_NAME
ForceCommand internal-sftp -u 0002


Restart your sshd process for the new settings to take effect






share|improve this answer












In your sshd config file, try setting "ForceCommand" on your groups



Match Group GROUP_NAME
ForceCommand internal-sftp -u 0002


Restart your sshd process for the new settings to take effect







share|improve this answer












share|improve this answer



share|improve this answer










answered Dec 29 '18 at 2:03









JohnJohn

1091




1091











  • Do you have some reason to believe the normal subsystem configuration isn't working here?
    – Kenster
    Dec 29 '18 at 19:10
















  • Do you have some reason to believe the normal subsystem configuration isn't working here?
    – Kenster
    Dec 29 '18 at 19:10















Do you have some reason to believe the normal subsystem configuration isn't working here?
– Kenster
Dec 29 '18 at 19:10




Do you have some reason to believe the normal subsystem configuration isn't working here?
– Kenster
Dec 29 '18 at 19:10

















draft saved

draft discarded
















































Thanks for contributing an answer to Unix & Linux Stack Exchange!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f491404%2fhow-to-get-sftp-to-respect-my-umask-setting%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown






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?