Reputation: 1360
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:
chmod 400 abc.pem
) -- Error: Server refused our key / No supported authentication methods available (server sent: publickey)
ssh -l user -i abc.pem user@ip
-- sometimes works*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:
ssh -l ubuntu -i abc.pem ubuntu@ip
ssh-add ~/keyfile.pem
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @ WARNING: UNPROTECTED PRIVATE KEY FILE! @ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ Permissions 0644 for 'cola-aws-ohio-key.pem' are too open. It is required that your private key files are NOT accessible by others. This private key will be ignored.
chmod 400
: Identity added: cola-aws-ohio-key.pem (cola-aws-ohio-key.pem)
~/.ssh/authorized_keys
looks same as beforeAny 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
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
Reputation: 1360
Here is how I solved the problem after many workarounds:
Updated MobaXterm -- I know
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 :
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