Investigate umask behavior
Based on our recent discussion, opening an issue to track investigation into umask behavior.
If we set the umask for the server process, we need the server to set the permissions on it, and/or see if there are any other consequences to this action (i.e. learn more about umask).
Details - the remote server socket inherits the user's umask when creating the socket. We can set umask, like to 0077 before starting the node process. But, then the umask will be inherited by the user's terminal and may not be what the user expects.
Chuck had the idea to add the umask during setup to limit the socket to just your user - the socket in this case being effectively "personal." We were wondering if there were any potential problems to look out for by doing this?
Thanks for the followup @roblourens For me it's more than a feature request. As explain in the linked issue #5567, files created by a user with a umask 022 will get different access rights depending the way the file is created (using VSCode with Remote/SSH extension or using the terminal) which is quite ... annoying :) Would be happy to help to test an incoming fix :) Thx for your help
We have the same problem as @zorrobiwan. we us VSCode with Remote/SSH. The remote server also hosts the git repo and when pushing commits it always messes up the permissions in the repo. That leads to other users not able to contribute to the same parts of code as they get permission denied errors. So we would really like to have a solution, maybe something similar to Remote/WSL https://github.com/microsoft/vscode-remote-release/issues/1518 ?
I have exactly the same problem as @zorrobiwan. When I create a new file, its permission becomes 664. Setting umask in /etc/profile or ~/.profile does not work.
To mitigate the problem, I run a chmod command for all files everytime I compile files so that I don't include the wrong permission files in a repository.
SSH FS (VSCode extension) has a function that allows a user to set a default permission. https://marketplace.visualstudio.com/items?itemName=Kelvin.vscode-sshfs

Permission is very important for security. I hope it will be fixed soon.
I found a solution. I added a line below in /etc/pam.d/sshd
session optional pam_umask.so umask=0027
Now, when I create a new file or directory in VSCode, the permission becomes as I set in /etc/pam.d/sshd. This setting is also effective for "ssh hostname command" and SCP connection.
It seems that if you login with ssh, it can read umask but VSCode connection, ssh command, nor SCP does not read umask. Anyway, I'm relieved that I found the solution which sets umask for all ssh connections.
Good to know there is a workaround ... Will test it later Thanks Yoshi!
session optional pam_umask.so umask=0027
That's very bad. Better is:
The default umask on my servers is 077. I've a dev-base-dir "/a41-dev".
as user "root":
mkdir /a41-dev/src
chmod 775 /a41-dev/src
chown root:users /a41-dev/src
setfacl -d -m u::rwx,g::r-x,o::r-x /a41-dev/src
as user "admin" ... member of users and umask = 077
mkdir /a41-dev/src/test-dir
touch /a41-dev/src/test-file
/a41-dev/src/test-dir will be createded with drwxr-xr-x /a41-dev/src/test-file will be createded with -rw-r--r--
... the default umask of 022 will be ignored. It also works with vscode.
For me this problem only occurs if I install the tunnel service with.
./code tunnel service install
If I remove the service and run the tunnel as my normal user on the remote server with
./code tunnel
the file permissions are as expected.
I am getting the same issues here. Is there any update? The vscode-server process has a different umask than the bash terminal. Is there a solution to this?
I found a work around.
vs-code server starts with a sh command, and seems to be a non-login shell.
If you can't make any modifications to your etc/profile for example do this:
Fix
- In
.vscode-server/bin/$COMMIT_ID/bin/code-server(normally located in ~/) on your desired remote server add your umask, (ex:umask 0002) before it calls the js file, the top, or under the case is fine. - On your local Ctrl + Shift + P and run Kill VS Code Server on Host.
- Make sure the code server is killed on your remote host. You can check this by running
pgrep -af code-serverwith a regular ssh in your terminal. - Connect to your server and create a file, see if it works.
Example of file
I believe the culprit is the bash shell that's opened by the SSH command. I described it in detail here: https://github.com/microsoft/vscode-remote-release/issues/11666