WSL SSH Sync
This skill automates the configuration required to safely share SSH keys between Windows and WSL (Windows Subsystem for Linux).
Problem
By default, WSL mounts Windows drives (e.g., /mnt/c) with 777 permissions. SSH requires strict permissions (600) for private keys. Standard chmod commands fail on WSL mounts unless the metadata option is enabled in /etc/wsl.conf.
Solution
This skill provides a script to:
- •Symlink the Windows
.sshdirectory to~/.sshin WSL. - •Check for the required
metadatamount option in/etc/wsl.conf. - •Apply correct permissions (
chmod 600) to keys and config files.
Usage
1. Run the Sync Script
Execute the provided script to set up the symlink and fix permissions.
bash
./scripts/sync_ssh.sh [windows_username]
If the Windows username is not provided, the script attempts to auto-detect it.
2. Verify Mount Options (Critical)
If the script warns about missing metadata options:
- •Edit
/etc/wsl.conf:ini[automount] options = "metadata"
- •Restart WSL (Required):
Run
wsl --shutdownin Windows PowerShell/CMD. - •Re-run the script or manually run
chmod 600 ~/.ssh/id_rsa.
Troubleshooting
- •"Bad owner or permissions": Ensure
~/.ssh/configis also set to 600. - •chmod has no effect: The drive is not mounted with
metadata. See step 2 above.