Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AWS EC2 pem key in txt

I am trying to launch aws ec2 server. I got a key pair, but my key looks like privatekey.pem.txt.

If I open it with text editor it looks like normal key, but how could I generate .pem file from it?

-----BEGIN RSA PRIVATE KEY-----
MIIEowIBAAKCAQEAh89 ...
like image 390
Alexander Vorontsov Avatar asked Nov 29 '25 03:11

Alexander Vorontsov


2 Answers

Have you tried simply renaming the file with a .pem extension? i.e. get rid of the .txt? My .pem file is also a text file (though not named as such) and it works just fine.

like image 154
E.J. Brennan Avatar answered Dec 01 '25 16:12

E.J. Brennan


You can either use AWS generated PEM key or custom PEM key you have on your computer.

When you generate your key from AWS console or CLI, you just get a PEM file which is your private key and you can use this key in your ssh command line for example. If this key is renamed by either you or your OS(add a .txt), you can just get rid of it and rename it to <key>.pem

When you generate your key by yourself(in RSA format), you have to transform your public key to PEM format before uploading it to AWS. You can do it using the following command:

ssh-keygen -f rsa.pub -e -m pem

Of course, wherever your key was generated from, you have to change permission:

chmod 400 <key>.pem
like image 44
Thomas L. Avatar answered Dec 01 '25 16:12

Thomas L.



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!