When generating an SSH key pair, both the public and private key will be generated. In some scenarios, you may need to copy the private key text and create a private key file.
For example, key pairs can be generated during instance creation. The public key will be stored on the instance, but you will need to copy the private key and create a private key pair file in order to connect to the instance later.
Steps
-
1
Open a text editor on your computer.
-
2
Paste the contents of the private key you just created into the text editor.
-
3
Provide a name for the file with a .pem extension and ensure you select the type as All Files. For example: private-key.pem
-
4
Save the file to a secure location on your computer.
-
5
If you are using macOS or Linux you need to run the following command to use your saved private key:
Open a terminal window on your computer.
Type in the following command:
chmod 600 /path/privatekeyname.pem
- /path/privatekey.pem is the location of the private key file