How to copying a SSH key from Windows to a Subsytem

I recently created a VM using the Azure CLI and had it generate SSH files. The problem was I did this from my Windows machine but wanted to use them on Ubuntu Subsystem.

The first thing I had to do was copy my id_rsa file from the Windows .ssh folder to my Ubuntu Subsytem. You cannot simply drag and drop files. Even the copy command is special because you must mount your Windows drive in the subsystem.

When the Azure CLI generates keys for you it stores them in C:\Users\{User}\.ssh. There will be two files created (id_rsa and You only need to copy the id_rsa file to the ~/.ssh folder of your subsystem. To copy the file first CD into ~/.ssh.

user@machine:~$ cd .ssh/

Now that you are there you can copy the file over.

user@machine:~/.ssh$ cp /mnt/c/Users/me/.ssh/id_rsa .

That was the easy part. When I tried to SSH into my VM I got the following error.


To correct this issue the follow command from the .ssh folder.

chmod 700 id_rsa 

This will correct the permissions on the file and allow the SSH command to work.


Add comment