How to Generate SSH Keys on a Mac

How to generate SSH keys on Mac OS X

Karl avatar
Written by Karl
Updated over a week ago

Note: This step is only done once, if you have already created your SSH keys, you can skip to part 2 of the file access guide: How to add your SSH key to the Templ Panel

Note 2: Instead of using SSH Keys, it's also possible to enable and use SSH/SFTP password.


Secure Shell (SSH) protocol uses encryption to secure the connection between a client and a server. All user authentication, and file transfers are encrypted to provide the highest possibly security. 

You will generate 2 SSH keys:

  • a public key 

  • a private key (stored safely on your computer, never give out your private key).

SSH key authentication provides the convenience of accessing your website files via SFTP without entering your passwords. SSH keys are also more secure than passwords, because the private key used to secure the connection is never shared.

You create SSH keys in Mac OS X using the ssh-keygen command in Terminal. We will describe in detail how to do this below.

How to generate SSH keys on Mac

Open up the Terminal app, this is the app you will be using to create your SSH key. The terminal app can be found in Finder > Applications > Utilities > Terminal.

You can also use Spotlight to find the Terminal app: Click the Command key (⌘) + Space on your keyboard and type Terminal and press Enter again to open the app.

To generate SSH keys in Mac OS, follow these steps:

1. Enter the following command in the Terminal window.

ssh-keygen -t rsa

This starts the key generation process. When you execute this command, the ssh-keygen utility prompts you to indicate where to store the key.

2. Press the ENTER key to accept the default location, without typing a passphrase. After that, the system generates the key pair.

Your identification has been saved in /Users/myname/.ssh/id_rsa.
Your public key has been saved in /Users/myname/.ssh/
The key fingerprint is:
ae:89:72:0b:85:da:5a:f4:7c:1f:c2:43:fd:c6:44:38 myname@mymac.local
The key's randomart image is:
+--[ RSA 2048]----+
|                 |
|         .       |
|        E .      |
|   .   . o       |
|  o . . S .      |
| + + o . +       |
|. + o = o +      |
| o...o * o       |
|.  oo.o .        |

Your private key is saved to the id_rsa file in the .ssh directory and is used to verify the public key.

You should never share your private key with anyone.

Your public key is saved to the;file and is the key you upload to your Templ Panel. You can save this key to the clipboard by using the following command:

pbcopy < ~/.ssh/

You can now paste your key in the Templ Panel using the Command key (⌘) + V. We will cover that process in the next part of the guide.

Did this answer your question?