Skip to content

Creating SSH key pairs on Mac

To create SSH key pairs on Mac, the built-in Terminal application is used, which is located in the Utilities folder under Applications.

Start Terminal and run this command

ssh-keygen -m PEM -t ecdsa -f ~/Desktop/anvil_key

This will create two key files on your Desktop, one public and one private, which can later be moved to whatever location you prefer.

A prompt will appear to enter a passphrase.  Press Enter twice to continue and create the key without a passphrase.

The command will complete and you will see a message saying the files have been created.

There will now be two key files on your Desktop.  The public key is named anvil_key.pub.  This public key will later be added to your Anvil account for SSH access to your instances.  The private key is named anvil_key (no .pub extension).  Treat the private key file the same as you would a password.  Keep your private key in a secure location and do not share it with anyone.

Example

$ ssh-keygen -m PEM -t ecdsa -f ~/Desktop/anvil_key
Generating public/private ecdsa key pair.
Enter passphrase for "/Users/user/Desktop/anvil_key" (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /Users/user/Desktop/anvil_key
Your public key has been saved in /Users/user/Desktop/anvil_key.pub
The key fingerprint is:
SHA256:I2qNRra86aQQJ4/iuRed/HM/9tunoQtUQg6YjJ+vriM user@MacBook-Pro.local
The key's randomart image is:
+---[ECDSA 256]---+
|     o o. .      |
|    . +  +       |
|     . .  o .    |
|      o    o     |
|o . = o.S .      |
| * = O ..o       |
|+ . X o.  .   .  |
|o.E*.o.o . + ....|
| ++o=+. o o.=+oo.|
+----[SHA256]-----+