Unable to change file permissions on Ubuntu Bash for Windows 10

If you're referencing files in the Windows file system, they do not, by default, retain Linux permissions. However, there's a way to enable that. Edit or create (using sudo) /etc/wsl.conf and add the following:

[automount]
options = "metadata"

Shut down all WSL instances and restart an instance, and any chmod changes are now retained.


Is the private key on your Windows filesystem (under /mnt/)? You can't modify the permissions of files on Windows's filesystem using chmod on Bash on Ubuntu on Windows. You'll have to copy the private key to your WSL home directory (~) and do it there.

Some discussion here: https://github.com/Microsoft/WSL/issues/81


The correct way to handle this:

  1. Create /etc/wsl.conf with the following:
    [automount]
    enabled  = true
    root     = /mnt/
    options  = "metadata,umask=22,fmask=11"
    
    To understand the meaning of each parameter above, please refer to this article on MSDN
  2. Close all WSL terminals and open a new one

Now you are all set; changing permissions of a file in Windows from /mnt/c/ will be reflected, and mounted, correctly within WSL on startup via the metadata option.