1

I have an Amazon ec2 set up running Ubuntu 14.04.

I have created a new user. My intent is to use ssh to log into my server with this user.

The login provided with the EC2 server works fine ssh -i key.pem ubuntu@ipaddress however I want to do this with my new user.

I have generated a key pair for this user and got the private key and public .pub key however I don't have a .pem key. I have done a little reading and some sources say that the private key is the .pem key I just need to add the extension.

Is this correct?

If not what is the correct way to generate a .pem key for this new user?

Additionally How to I download this .pem key to my local machine.

I really am looking for the simpliest answer here. I have read several similar posts but often the answer goes into too deep of detail into what .pem means I am just looking for a simple answer.

  • Question 1: Are .pem and private keys the same thing when generated using sshkeygen?
  • Question 2: What is the correct way to generate a .pem file on ubuntu
  • Question 3: what is the correct way to transfer files from a remote host to your local machine
  • 1
    The level of this question makes it hard to provide a good answer. A .pem file does normally include a key. A simple way to transfer a key is to use copy-paste since it is text. – Julie Pelletier Sep 1 '16 at 2:26
  • To complicate a little: PEM format can be and in general is used for a lot of things, many of which don't use .pem as a file suffix, but OpenSSH in particular including ssh-keygen always puts a private key in a PEM file and only occasionally uses a PEM file for anything else, so in the context of your question PEM format (regardless of file name) means a private key. – dave_thompson_085 Sep 4 '16 at 9:35
2

Question 1: Are .pem and private keys the same thing when generated using sshkeygen?

Usually yes.

Question 2: What is the correct way to generate a .pem file on ubuntu

Use ssh-keygen. It will not generate pem, but id_rsa in ~/.ssh/, but it is standard way to go.

Question 3: what is the correct way to transfer files from a remote host to your local machine

Use ssh-copy-id. For specific key and host, it would be ssh-copy-id -i /path/to/key.pem host. After the prompt for password, the keys should be copied over and properly set up, if the remote system has standard settings.

  • ssh-keygen defaults filename(*) to ~/.ssh/id_$type (and type to rsa) but you can change it. The only advantage of the standard name is the client looks there by default without needing the -i flag or equivalent configuration. (*: except rsa1 defaults to identity, but rsa1 is two decards obsolete and should never be used.) – dave_thompson_085 Sep 4 '16 at 9:39
0

@Daniel, everyone would probably give you the same advice, tread lightly. There is the way to do it, and the way not to do it. Unfortunately, it looks like the web appears to have turned into a hack fest. So if you are going to leave a servers on the web in a public space, with ports open and private keys and no passwords, it is likely to get hacked...eventually. Some WordPress websites I have supported get hammered all day long. For that sack, with two large websites I supported it was the same.

As you have an ec2 running ubuntu 14.04.x, you would have generated a private key when you created the instance. Keep it private and safe. And use it to connect to your server, as is if you are using Mac. On windows use a program like Bitvise. Make sure your account is the only one that can connect to the ec2 instance on port 22, and lock down all other ports in your security groups, with port 80, 443 open for web servers, it's the minimum you should do. There is plenty more security you should do. It's all on the AWS website. Don't be lulled into the media's view that hacked websites are an anomaly.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.