Windows 10/11 WSL chmod

There is a major problem using Windows 10/11 Windows Subsystem for Linux WSL. It shows up when trying to adjust a SSH private key permissions to Read Only. This is a requirement when trying to connect SSH (port 22) to a remote Linux server. It is required when connecting to nearly any version of Linux. You can use SSH directly on via Windows, but you have to jump through a large number of hoops when trying to use acls.exe to adjust permissions. If Microsoft is going to give you Linux integrated with their operating system, why not use it and make your life easier when connecting to a Linux system.

Configure WSL for Linux metadata

When creating an SSH key pair via ssh-kegen, AWS or Azure on a Windows 10/11 system, they are placed in the c:\user\<usermane>\.ssh folder. This is an NTFS file system. To set permissions correctly, open the WSL (Ubuntu) bash shell and create a file called wsl.conf under /etc. (eg: vi /etc/wsl.conf). Insert the text below and save.

[automount]
options = “metadata”

Shutdown WSL (wsl –shutdown) and relaunch Ubuntu. Change directory to:

/mnt/c/users/chest/.ssh and run chmod 400 <private key>. When you run ls -al you can see that the file permissions are set properly.

That’s it. Now you can use your private key to connect to another Linux system.

Author: Chet Camlin

Leave a Reply