SSH keys are the perfect way to securely connect to your server over SSH/SFTP. At Pagely, we take your security very seriously and require all of our VPS and Enterprise hosting customers to use SSH keys when authenticating with their environments. In this article, we'll show you how to generate a new SSH key pair on MacOS.
Checking For Existing SSH Keys
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:
- Open a new Terminal window.
- Inside your terminal, enter the following to list your SSH keys:
ls -al ~/.ssh
- Did you see any files ending in .pub, usually id_rsa.pub? That means you already have an SSH key configured! If you want to use an existing SSH key, you can skip the next section on generating SSH key pairs and head right over to learning how to get the contents of your public key.
Generating a New SSH Key Pair
Ready to generate a new SSH key? Awesome! Let's get started:
- Open a new Terminal window.
- Next, generate a new SSH key pair using the following command:
ssh-keygen -t rsa
- After you enter the ssh-keygen command, you'll be asked where you want to save your key pair. Unless you have a specific reason for storing your SSH key elsewhere, the default path and id_rsa filename will be fine. Just leave the prompt blank and press Enter to use the default location.
- Next, you'll be prompted to enter a password for your key. We recommend that you secure your SSH keys with a password for additional security.
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. Be sure to keep your private key as safe as you would a password.
Getting Your SSH Public Key
Need to get your SSH key to add it to your Pagely account? Here's how to do it:
- Open a new Terminal window.
- Enter this command to get your SSH key:
cat ~/.ssh/id_rsa.pub
Next Steps: Adding Your SSH Key to Atomic
If you want to connect to your Pagely VPS using SSH/SFTP, you'll need to associate your new SSH key with your Pagely account. To learn more about how to do this, take a look at our article on adding SSH keys to your Pagely account.