I am left pondering why this is happening. I wanted to ssh connect to my AWS EC2 instance from WSL, but even after chmod 400 ___.pem multiple times it still returns
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@ WARNING: UNPROTECTED PRIVATE KEY FILE! @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Permissions 0555 for '________.pem' are too open.
It is required that your private key files are NOT accessible by others.
This private key will be ignored.
Load key "________.pem": bad permissions
ubuntu@_______.compute-1.amazonaws.com: Permission denied (publickey).
I then decided to follow the advice at https://www.youtube.com/watch?v=mrUqITjUhL8
and did the same things on both WSL and powershell, well the end result is that using the very same commands and modifying the file permissions through file explorer results in poweshell being able to connect to the EC2 instance, but the WSL still being unable to connect due to the same error message.
I am wondering if I am missing something,I would really like to use WSL to work with AWS
2
Answers
You are missing that file permissions work differently in Linux than Windows. You need to fix the Linux file permissions on the file via the
chmod
command instead of using the Windows file explorer.If you are using the same file in both Windows and Linux, you first need to make a copy of it over on the Linux side, probably in your
~/.ssh
folder, and then do achmod 600
on the file.If you’re referencing files in the Windows file system, they do not, by default, retain Linux permissions. However, there’s a way to enable that. Edit or create (using
sudo
)/etc/wsl.conf
and add the following:Close all WSL terminals and open a new one.
Note: If the private key is on your Windows filesystem (under /mnt/), You can’t modify the permissions of files on Windows’s filesystem using chmod on Bash on Ubuntu on Windows. You’ll have to copy the private key to your WSL home directory (~) and do it there.