Skip to content

Instantly share code, notes, and snippets.

@davidrobertbrt
Last active January 14, 2024 23:58
Show Gist options
  • Save davidrobertbrt/b7de13befc797b2e6fdf7334808be8e5 to your computer and use it in GitHub Desktop.
Save davidrobertbrt/b7de13befc797b2e6fdf7334808be8e5 to your computer and use it in GitHub Desktop.
How to share SSH keys between Windows and WSL2

How to share SSH keys between Windows and WSL2

Copy keys from Windows in WSL2

To copy ssh keys from Windows, use the mnt folder in which you will find your Windows partitions.

cp -r [PATH_TO_SSH_KEYS_FOLDER_WINDOWS] ~/.ssh

For example, for the .ssh folder which is stored by default in C:\Users\<username>\.ssh you would write:

cp -r /mnt/c/Users/<username>/.ssh ~/.ssh

Fix permissions

If you try to push something using Git, you might get a warning message that it doesn't recognize the remote host. If you type yes in the Bash prompt you will get an error saying WARNING: UNPROTECTED PRIVATE KEY FILE!. This is because, by default, the keys stored will have chmod 755. To fix this, just type:

chmod -R 600 ~/.ssh/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment