SSH Keys
SSH keys are a form of access credential used in the SSH protocol. They come in pairs - a private key and a public key. To authenticate a key, you generally save the public key (never the private one) on the service which you are connecting to via SSH. When you are on the machine which has the private key associated with that public key, it will be authenticated.Creating an SSH key
- Open your terminal. On macOS, you can find this in Utilities in the Applications folder.
- Run the following command in the terminal:
- It then asks you a couple of questions:
- It prompts you about where to store the key, the default location is fine
- It prompts you for a passphrase. You can add one or leave this blank
- After you confirm, it generates the key pairs and stores them in
/Users/<USERNAME>/.ssh/asid_rsaas the private key andid_rsa.pubas the public key
Authenticating with the SSH key
To get the public key, you can run the following command in your terminal:ssh-rsa in your terminal. You can copy and paste that key onto the service you want to authenticate with.