Unix permissions on WSL NTFS mount

WSL suffers from missing unix permissions for Windows mounts.
Storing ssh keys on NTFS and having it mounted on any WSL environment will not meet file permissions requirements. The files on the NTFS mount will have 777 which is far too open.
SSH agent will complain about file permissions set too open. NTFS does not support unix permissions, but you’d like to edit those files with your Visual Studio Code editor on Windows and run it from within WSL.
DrvFs rushes to the rescue. Options are introduced with the
Windows 10 Fall Creators Update that will improve the situation.

To enable the capability to set unix permissions on NTFS mounts inside WSL you have to do the following:

Create /etc/wsl.cfg with following content inside the affected WSL environment:

[automount]
enabled = true
root = /mnt/
options = "metadata,umask=22,fmask=11"
mountFsTab = false

To apply the change, I restarted the LxssManager service using Powershell.

 Restart-Service -Name "LxssManager" 

Using the mount command inside WSL you should be able to check the mount option of “C:”.

From now on, unix-style permissions on NTFS are kept.
Further documentation:

https://docs.microsoft.com/en-us/windows/wsl/wsl-config#set-wsl-launch-settings

2 thoughts on “Unix permissions on WSL NTFS mount

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.