gonzalez.ivan90
gonzalez.ivan90

Reputation: 1360

.ppk derived from .pem key works but .pem don't in MobaXterm or file transfer programs

I have an ec2 instance and it .pem key file, which I want to use for transfer files from my local machine to the server

I tried to connect the instance by using:

Apparently I messed up the ~/.ssh/authorized_keys file, and the .PEM key is not allowed to connect the instance.

At this point the authorized_keys file have one row like this: ssh-rsa AAAAB3Nza....

Then I did chmod 400 abc.pem and tried the followings:

I tried:

Any ideas on how to solve this? It is weird that ppk key (derived from pem file) works but the original pem key doesn't.

Upvotes: -1

Views: 1325

Answers (2)

Mansoor Ur Rehman
Mansoor Ur Rehman

Reputation: 1

amazon linux 2023 and ubuntu 22 user updated version of openssl, you need to get a updated key ssh-keygen -o -a 100 -t ed25519

Upvotes: -1

gonzalez.ivan90
gonzalez.ivan90

Reputation: 1360

Here is how I solved the problem after many workarounds:

  1. Updated MobaXterm -- I know

  2. Be sure about a.pem permissions. I'm on Windows with WSL too. The file's permission is -rwxrwxrwx but should be -r-------- (-r--r--r-- also works for me)

I tried chmod 400 a.pem, and it only works if the file is located on Ubuntu/Linux internal folder (~), not on the Windows shared folder (/mnt/c/...). However, when I tried copy the file from Ubuntu/Linux internal folder to Windows (where MobaXterm can use it), the permission changed back to -rwxrwxrwx

I also tried :

  • zip and tar the key on Ubuntu, and uncompress on Windows: Fail
  • Upload to Github from Ubuntu and download in Windows: Fail
  • Cheange manually the permission on Windows: Fail

So I changed the permissions in Windows using PowerShell as admin, with the following code:

cd C:\mydir
icacls.exe a.pem /reset
icacls.exe a.pem /grant:r "$($env:username):(r)"
icacls.exe a.pem /inheritance:r

Apparently the combination of updating MobaXterm and being sure about file permissions were the way this works

Upvotes: -1

Related Questions