To use your new (or existing) SSH key for QCS, you'll need to add it to your QCS account.
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 id_rsa.pub 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
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 "email@example.com"
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
id_rsa.pub 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.
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.
ssh-add -K ~/.ssh/id_rsa
Finally, copy your SSH key to your clipboard by entering the following command:
pbcopy < ~/.ssh/id_rsa.pub