Convert a pem file into a rsa private key

By: Luke Rawlins Jul 14, 2018 | 1 minute read
Share this:

Tags: aws, ec2, Linux, ssh

lock

When you build a server in AWS one of the last steps is to either acknowledge that you have access to an existing pem file, or to create a new one to use when authenticating to your ec2 server.

If you want to convert that file into an rsa key that you can use in an ssh config file, you can use this handy dandy openssl command string.

openssl rsa -in somefile.pem -out id_rsa

Note: you don’t have to call the output file id_rsa, you will want to make sure that you don’t overwrite an existing id_rsa file.

Copy the id_rsa file to your .ssh directory and make sure to change permissions on the id_rsa key to read only for just your user.

chmod 400 ~/.ssh/id_rsa

Related Posts


How to get started using Ansible

Install Ansible On most Linux distributions Ansible can be installed directly through your distribution’s package manager. For those using macOS or a distribution that doesn’t package Ansible, you can install it via python pip. The Ansible docs have a really good walkthrough for installation that can be found here:http://docs.ansible.com/ansible/latest/installation_guide/intro_installation.html I won’t repeat those instructions except to say that you will want to make sure that the computer you install Ansible on should have Python 2. Read more

Three reasons to start using Ansible

A few months ago I attended a one day Ansible workshop in Columbus Ohio with a colleague. The workshop was sponsored by Red Hat and contained several labs, which is well worth your time if you have the opportunity. I wasn’t sure what to expect, generally you don’t walk away with much working knowledge from these short events, but I had some experience with Puppet (most of it frustrating) and I was curious to see what Ansible could do for my organization. Read more

The caret is mightier than the up arrow

I learned a fun bash trick a while ago that I thought I would share. In a bash shell you can use the caret ^ symbol to find and replace a sequence of characters in your previous command. For instance if you type: sudo systemctl restart httpd and then want to look at the status of the httpd service all you need to do is: ^restart^status Bash will look at the last command in your history and replace the first occurrence of “restart” with “status” and run the new command. Read more


Contact

If you’d like to get in touch, contact with me via email - or follow on Twitter.

[email protected]