3

I'm trying to format a .pem file for access to an EC2 instance through SSH, but no matter what I try among suggestions I've seen, nothing seems to work. For context, I have the .pem file stored on my Windows C:// drive.

From just downloading it, I get the following permissions as seen in my WSL shell (and output of ssh command, fails, obviously): enter image description here

The following are my attempts to modify this file

  1. Used Ubuntu's WSL to chmod the file into 400 (what I assume is -r--------): (forgot to unhide my username, lol) enter image description here

1.a. I have modified my wsl.conf with the following to make sure to allow permissions changes to propagate from my WSL shell (Unable to change file permissions on Ubuntu Bash for Windows 10):

enter image description here

  1. Used Powershell to try to place restrictions on the file (https://stackoverflow.com/questions/39404087/pem-file-permissions-on-bash-on-ubuntu-on-windows): enter image description here

Now, permissions are `-r--r--r--', which still isn't good enough.

enter image description here

  1. Made sure the file is only readable by user in Windows settings (Windows SSH: Permissions for 'private-key' are too open):

enter image description here

What else can I do here? This is literally all the answers I've found online and they don't work. Any help is appreciated. Thanks y'all!

EDIT: After some reading, it seems that Powershell has some extra ways to reset permissions but I can't seem to find any definitive source.

5
  • Does this answer your question? Unable to change file permissions on Ubuntu Bash for Windows 10 Commented Dec 29, 2021 at 23:48
  • As I mentioned before, I've already tried changing the wsl.conf and it didn't work. Thanks tho!
    – Daneolog
    Commented Dec 30, 2021 at 1:51
  • Not exactly how amazon describes importing a key ... Have you tied the methods laid out in their own documentation on docs.aws.amazon.com/AWSEC2/latest/UserGuide/… ?
    – Silbee
    Commented Dec 30, 2021 at 1:58
  • I'm not importing a key, simply using one I downloaded and created when I initialized the instance. The problem I'm trying to solve here is how to change permissions so it can be usable when ssh'ing into my instance.
    – Daneolog
    Commented Dec 30, 2021 at 2:59
  • 1
    Unfortuntaly i dont know why WSL doesnt allow chmod 400. I did find someone's solution was to copy the cert to their WSL home directory (~) and chmod 400 there without problems. (link to discussion github.com/Microsoft/WSL/issues/81)
    – Silbee
    Commented Dec 30, 2021 at 13:17

1 Answer 1

5

WSL will start in your C:\Users{user} directory.

Put the file in /home/{user}, then change the permissions.

1
  • thank you for the help! yes, @Silbee gave the answer to do this as well, and I ended up following it. I appreciate the help though!
    – Daneolog
    Commented Mar 19, 2022 at 8:43

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .