Let’s say you want to setup a Gitlab server on AWS and you need to do a git clone using SSH protocol. You will be annoyed by the .pem file. To get rid of it (or more simply hide it) you can follow this procedure:

The pem file contains a private key. Simply extract it and add it to your system.

Copy the private key to the .ssh folder:

1
cp /path/to/your/cert.pem ~/.ssh/id_rsa_gitlab_ec2

Generate a public key from the .pem file:

1
ssh-keygen -y -f /path/to/your/cert.pem > ~/.ssh/id_rsa_gitlab_ec2.pub

Add the private key to ssh-agent:

1
2
3
4
5
# Start ssh-agent
eval "$(ssh-agent -s)"

# Add your newly created key to the agent
ssh-add ~/.ssh/id_rsa_gitlab_ec2

Now try to connect to you EC2 instance via SSH:

1
ssh [email protected]

Try to git clone .... All good !