Home
/
Advanced Site Tools
/
SSH
/
How to generate an SSH key pair in Mac OS?

How to generate an SSH key pair in Mac OS?

SiteGround uses key pairs for SSH authentication purposes, as opposed to plain username and password. More information on SSH keys is available here.

You can generate an SSH key pair in Mac OS following these steps:

  • Open up the Terminal by going to Applications > Utilities > Terminal
  • In the terminal, use the following command to start the key generation
ssh-keygen -t rsa
  • Next, you will be prompted to provide the location where you want to create the private key file:
Enter file in which to save the key (/home/youruser/.ssh/id_rsa):

Leave this empty to create the key in the default location, which is /home/youruser/.ssh/id_rsa. The public key file will be created in the very same location, and with the same name, but with the .PUB extension.

  • Afterwards you will be prompted to choose a password. This is the password required to use the private key.
Enter passphrase (empty for no passphrase):

That completes the key generation. Below is an example of the entire process:

Mac_user: ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/home/user/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in id_rsa.
Your public key has been saved in id_rsa.pub.
The key fingerprint is:
16:8e:e8:f2:1d:c9:b9:cf:43:9a:b3:3c:c1:1f:95:93 Mac_user

This will create a private key written to /home/user/.ssh/id_rsa and a public key written to /home/user/.ssh/id_rsa.pub.

After that you will have to upload the public key in Site Tools > Devs > SSH Keys Manager, go to Import and paste the key. Load the private key in your Terminal using the ssh-add command:

ssh-add /home/user/.ssh/id_rsa

You will be asked for the passphrase of your key when loading it in the Terminal.

With the generated keys, you should now be able to connect via SSH. More information on how to connect via SSH to your SiteGround hosting account can be found below:

How to log in to my SiteGround shared account via SSH in Mac OS

Share This Article