An SSH key consists of a pair of files. One file is the private key, which you keep to yourself and never give out to anyone. The other is a public key which you share with other people or platforms. Key pairs are handy when you are provisioning cloud environments because they give you a simple way to access the platform.
Generate an SSH Key
To generate an SSH key, you will need to use the ssh-keygen utility. The ssh-keygen utility stores the keys in a safe location so you can bypass the login prompt when connecting to a remote/cloud server.
To generate your SSH Keys in a Mac OS environment, follow these steps:
1. Open a Terminal windows
2. Start the key generation process by issuing. Press enter to accept the default location (~/.ssh). Then you will be promoted to provide a password. Password will need to be provided twice.
$ ssh-keygen -t rsa
After you provided the password, the system will save your private key (id_rsa) in the ~/.ssh directory. DO NOT SHARE THIS FILE WITH ANYONE!
There will be a file called id_rsa.pub which is your public key. This key can be shared with whoever needs it and uploaded to remote/cloud servers.