Mac/Linux: Adding a new SSH key to your QCS account

To use your new (or existing) SSH key for QCS, you'll need to add it to your QCS account.

Check for existing SSH keys

Prior to generating a new SSH key, you can check if you already have an existing one. Open your Terminal, and enter the following command:

ls -al ~/.ssh

This lists all the files in your .ssh directory. By default, the filenames of the public keys are one of the following:

If you see a key pair listed (for example and id_rsa) that you would like to use for connecting to your QMI, you can skip ahead to the instructions below for adding your SSH key to the ssh-agent.

Otherwise, if you don't have an existing public and private key pair, or if you get an error that ~/.ssh doesn't exist, then follow the instructions below for generating a new SSH key

Generating a new SSH key

The standard OpenSSH protocol uses ssh-keygen to generate key pairs. Run it on your computer by opening your terminal and enter the command:

ssh-keygen -t rsa -b 4096 -C ""

You'll be prompted to select the location for saving the keys. By default, they are stored in the ~/.ssh directory with the file names id_rsa for the private key and for the public key. We recommend just pressing Enter to use these default locations and file names to avoid potential issues when connecting to your QMI later.

Enter a passphrase if you'd like, or just hit ENTER to skip. You now have a public and private key that you can use to authenticate.

Adding your SSH key to ssh-agent

First, start the ssh-agent by entering the following in your terminal:

eval "$(ssh-agent -s)"

If you're using macOS Sierra 10.12.2 or later, you will need to modify your ~/.ssh/config file to automatically load keys into the ssh-agent and store passphrases in your keychain.

Host *
&nbnsp; AddKeysToAgent yes
&nbnsp; UseKeychain yes
&nbnsp; IdentityFile ~/.ssh/id_rsa

Add your SSH private key to the ssh-agent and store your passphrase in the keychain. If you created your key with a different name, or if you are adding an existing key that has a different name, replace id_rsa in the command with the name of your private key file.

For Mac:

ssh-add -K ~/.ssh/id_rsa

For Linux:

ssh-add ~/.ssh/id_rsa)}

Add your SSH key to QCS

Finally, copy your SSH key to your clipboard by entering the following command:

pbcopy < ~/.ssh/

Note: If you've created a custom filename for your SSH key (i.e. it is not named, then modify the above pbcopy command to match your custom filename.