How to connect to Linux PC using built-in ssh in Windows

Recently I figured out that Windows 10 has a built-in ssh application. Great! If you would like to connect to Linux PC using it, you need to use the following command:

ssh -i key.pem username@ipaddress_or_host

But if you will try to run it you will get following error:

@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@

@         WARNING: UNPROTECTED PRIVATE KEY FILE!          @

@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Permissions for 'key.pem' are too open.
It is required that your private key files are NOT accessible by others.
This private key will be ignored.

It is a very strange error message. I would say it is the typical Linux way. A smart person will figure it out and a dumb person doesn’t need it. What it trying to tell, that this file can be accessed by other people on your computer. I honestly do not understand what’s wrong with it because I’m not trying to make it accessible to other people. They already able to access it.

Anyway, to fix it you have to execute following commands:

icacls key.pem /inheritance:r
icacls key.pem /grant:r "%username%":"(R)"

Credit to Walter Ferrao.

I hope it will help someone.

Comments

Post comment