Create, Access and Use SSH Keys with macOS

macOS macOS

SSH or "Secure Shell" is a network protocol for operating networked services securely. It is typically used for remote command-line authentication and command execution.

In this tutorial I will show you how you can create, access and use your SSH key for macOS.

1. Open Terminal and Navigate to .ssh

Open up your terminal and navigate to your ssh folder.

cd .ssh

2. Create your SSH key

We can create an SSH key with the ssh-keygen command in the terminal.

ssh-keygen -t rsa

3. Name your SSH key

You will also be asked to choose a name for your SSH key if you already have previously created keys.

Enter file in which to save the key (/Users/username/.ssh/id_rsa): your-key-name

4. Choose a password for your SSH key

When you have named your SSH key you will be asked to enter a password for the SSH key, twice to make sure that the password match. 

Enter passphrase (empty for no passphrase):
Enter same passphrase again:

5. Verify that your SSH key has been created

If your SSH key was created sucessfully your SHA256 fingerprint along with the randomart should be desplayed in the terminal.

Your identification has been saved in your-key-name.
Your public key has been saved in
The key fingerprint is:
SHA256:y31xp0ynRklGKx5i/Lv9bcD7VDfRaboliEk2YzXlhGY username@computer
The key's randomart image is:
+---[RSA 2048]----+
|       o=E=.+ +  |
|      . .*.    . |
|        O=o= O ..|
|         S o= B .|
|        .o.  = +o|
|       . + .o + B|
|        + o .+ Bo|
|       .     .*Lo|
|             .o.o|

The randomart might look funky or down right cryptic, but it actually meant to be an easier way for humans to validate keys. Rather than comparing a long hexadcimal string the randomart is both faster and easier to compare. However, if you are creating an SSH key for your server or a service, you will rarely use them. 

6. Access & copy your SSH key

Now that we have created our SSH key we can use the ls command and see that the public and private key is located in our ssh folder.



In order to authenticate yourself with third-party services that uses SSH authentication they need to be aware of your public key. We can access and copy the public key by using the pbcopy command. 

pbcopy < ~/.ssh/

That's how you create and access an SSH key on macOS. How you use it will vary for each service or use case. Most services should provide documentation to get you started. If you for example want configure SSH for Github, they provide their own documentation for it.

Did You Enjoy the Tutorial?

Consider sending some love to Freddie the creator.

Comments (0)

You need to be logged in to comment..

Topics Mentioned in this Tutorial

MacOS (Macintosh Operating System) is an operating system create by Apple for their line of laptops and desktop computers. MacOS features a sleek design with a global menu, dock and multi tasking features combined with the security and stability that so many has come to love. The operating system was first introduced in 1984 as Macintosh System Software, which later became System Software 2,3,4,5 and 6 the Mac OS 8,9. Then moved on to the OS X convention between 2001-2015 and now has settle with the current naming convention for the foreseeable future....
SSH or "Secure Shell" is a network protocol for operating networked services securely. SSH is widley used for remote command-line authentication and command execution for servers and services. ...