{"action":"created","issue":{"url":"https://api.github.com/repos/mscdex/ssh2/issues/150","labels_url":"https://api.github.com/repos/mscdex/ssh2/issues/150/labels{/name}","comments_url":"https://api.github.com/repos/mscdex/ssh2/issues/150/comments","events_url":"https://api.github.com/repos/mscdex/ssh2/issues/150/events","html_url":"https://github.com/mscdex/ssh2/issues/150","id":36666930,"number":150,"title":"Can't get \"mode\" option to work","user":{"login":"callumlocke","id":250617,"avatar_url":"https://avatars.githubusercontent.com/u/250617?v=3","gravatar_id":"","url":"https://api.github.com/users/callumlocke","html_url":"https://github.com/callumlocke","followers_url":"https://api.github.com/users/callumlocke/followers","following_url":"https://api.github.com/users/callumlocke/following{/other_user}","gists_url":"https://api.github.com/users/callumlocke/gists{/gist_id}","starred_url":"https://api.github.com/users/callumlocke/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/callumlocke/subscriptions","organizations_url":"https://api.github.com/users/callumlocke/orgs","repos_url":"https://api.github.com/users/callumlocke/repos","events_url":"https://api.github.com/users/callumlocke/events{/privacy}","received_events_url":"https://api.github.com/users/callumlocke/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2014-06-27T14:11:09Z","updated_at":"2015-01-26T00:41:07Z","closed_at":"2015-01-26T00:41:07Z","body":"I'm trying to create a remote directory like this:\r\n\r\n`sftp.mkdir(currentDir, {mode: '0775'}, function (err) {`\r\n\r\nBut the directory always gets created with permissions `755`. \r\n\r\nI've tried setting it with `'0775'`, `'775'`, and `parseInt('0775', 8)`, but it never seems to take effect.\r\n\r\nAm I doing it wrong?\r\n\r\nAlso, when I upload a file with `fastPut`, there's no documented way to set the permissions for that file. I tried adding `{mode: '0775'}` but it always gets created with `644`. I don't know if this is a separate issue or not."},"comment":{"url":"https://api.github.com/repos/mscdex/ssh2/issues/comments/71402639","html_url":"https://github.com/mscdex/ssh2/issues/150#issuecomment-71402639","issue_url":"https://api.github.com/repos/mscdex/ssh2/issues/150","id":71402639,"user":{"login":"mscdex","id":54666,"avatar_url":"https://avatars.githubusercontent.com/u/54666?v=3","gravatar_id":"","url":"https://api.github.com/users/mscdex","html_url":"https://github.com/mscdex","followers_url":"https://api.github.com/users/mscdex/followers","following_url":"https://api.github.com/users/mscdex/following{/other_user}","gists_url":"https://api.github.com/users/mscdex/gists{/gist_id}","starred_url":"https://api.github.com/users/mscdex/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mscdex/subscriptions","organizations_url":"https://api.github.com/users/mscdex/orgs","repos_url":"https://api.github.com/users/mscdex/repos","events_url":"https://api.github.com/users/mscdex/events{/privacy}","received_events_url":"https://api.github.com/users/mscdex/received_events","type":"User","site_admin":false},"created_at":"2015-01-26T00:41:07Z","updated_at":"2015-01-26T00:41:07Z","body":"So the problem here is the umask that the OpenSSH SFTP server is using. For example, the default umask on Ubuntu (for me) is 0022. So trying to create a directory with 0775 will result in 0755 as you noted, because the umask overrides our mode.\r\n\r\nAn easy way to change this is to pass in the desired umask to the sftp server in the `/etc/ssh/sshd_config`. For example: `Subsystem sftp /usr/libexec/openssh/sftp-server -u 0002`. If your version of OpenSSH does not support `-u` you can use `Subsystem sftp /bin/sh -c 'umask 0002; /usr/libexec/openssh/sftp-server'` instead. Replace `/usr/libexec/openssh/sftp-server` with `internal-sftp` if you are using the internal sftp server."}}