Creating key pairs with AWS is rather easy but for convenience and security reasons generating your own SSH keys and importing them into AWS can be a good option.
From a security stand point generating your own key pair means that you can know 100% that the private key has never seen the light of day… or any other computer other than the one you generate it on.
If you are using multiple regions in AWS then generating your own key pair and importing it gives you another benefit – you can use the same key globally rather than having to create one per region.
On Ubuntu the process of generating a key pair is as simple as running the following command.
This will prompt you to enter a name for the key and then a pass-phrase – this can be left blank if you wish… I usually leave this blank because I don’t want to enter a password every time I use the key.
Once you have entered the required details you will have two files which have been generated for you: <keyname> and <keyname>.pub where <keyname> is the name you chose.
You can now import the .pub file into the Key Pairs section of the EC2 console, usually located here.
You can import this same public key into as many different regions as you wish which enables you to connect to all of your servers with the same private key – much simpler than keeping track of a key for each region.
Now you are good to go, you will be able to launch new instances with your created key pair safe in the knowledge that your private key is as secure as can possibly be.
If you want to use this newly created key on your existing instances then check out my post on replacing SSH keys on running instances.