What is WSL?
Windows Subsystem for Linux (WSL) lets you run a Linux environment directly on Windows — including tools like grep, sed, awk, and SSH. This guide uses Ubuntu 18 on Windows 10.
The Problem
If you run chmod inside WSL to set permissions on a file (e.g., a .pem key), the change doesn’t stick. Windows and Linux handle permissions differently, so WSL ignores chmod by default unless you configure it to respect Linux metadata.
For SSH keys (.pem, .cer), you typically need permissions set to 600 (rw-------). Without the fix below, you’ll see “permissions are too open” errors.
Fix: Enable metadata in WSL
Step 1: Create or edit /etc/wsl.conf
1 | sudo nano /etc/wsl.conf |
Add the following:
1 | [automount] |
Save with Ctrl + X, then Y, then Enter.
Step 2: Shut down WSL
Open a regular Windows Command Prompt (not WSL) and run:
1 | wsl --shutdown |
Step 3: Apply permissions
Re-open Windows Terminal, switch to Ubuntu, then set your permissions:
1 | chmod 600 mykey.pem |
Step 4: Verify
1 | ls -l mykey.pem |
You should see:
1 | -rw------- 1 user group ... mykey.pem |