Generating an SSH key pair on macOS
When you're working with payments, security is a top priority. Rather than typical password authentication that can be easily circumvented, we require authentication via SSH key pairs to connect over SFTP. In this article, we'll show you how to generate an SSH key pair on MacOS.
Check for existing SSH key pairs
Before generating a new SSH key pair, you might want to first check to see if you already have any SSH keys present. Here's how to check:
- On your computer, open a new Terminal window.
- Inside your terminal window, enter the command to list any existing SSH key pairs:
ls -al ~/.ssh
If you see any files ending in
id_rsa.pub), you already have an existing SSH key pair. If you want to continue using this existing key pair, you're free to skip the next section and head on over to grabbing the contents of your public key.
If you'd prefer to use a different key pair, the next section will show you how to generate one.
Generate a new SSH key pair
Ready to generate a new SSH key? Awesome! Let's get started:
- Start by opening a new Terminal window or if you followed the previous section, you can use the one that's already open.
- Next, issue the following command to generate a new SSH key pair:
ssh-keygen -t rsa
After entering the
ssh-keygencommand, you'll be asked where you want to save your key pair.
Unless you have a specific reason for storing your SSH key elsewhere, such as if you already have an existing key pair that you want to keep, the default path and
id_rsafilename will be fine. Just leave the prompt blank and press the Enter key to use the default location.
- Lastly, you'll be prompted to secure your SSH keys with a password. While this step is optional, we highly recommend setting a passphrase as a security best practice.
Your SSH key pair has now been generated! This includes a public key that will be named
id_rsa.pub and your private key labeled
id_rsa. Since this private key controls access to your account, be sure to keep your private key as safe as you would a password.
Get your SSH public key
After your key pair has been generated, you'll need to access your public key. Here's how to do it.
- Open a new Terminal window or use an existing open window.
- Enter the following command to output the contents of your public key:
Note: The following command assumes that your key pair is named
id_rsaas described in previous steps. If you're using a key with a different name, you'll need to adjust the command accordingly.
With an SSH key pair in hand, you're almost ready to connect to your site over SFTP. Next, you'll need to associate the public key with your Managed WooCommerce Stores account.