Add SSH keys
You can add SSH keys for use in connecting to remote servers, such as an AWS EC2 instance.
Add SSH Credential
To add an SSH key that can be referenced in Harness entities, do the following:
Select your Account/Organization/Project.
In ACCOUNT SETUP/ORG SETUP/PROJECT SETUP, Click Secrets.
Click New Secret and select SSH Credential.
The SSH Credential settings appear.
Enter a Name for the SSH Credential and click Continue.
Under Select an Auth Scheme, select one of the following:
- SSH Key: add SSH keys for Harness to use when connecting to remote servers.
- Kerberos: SSH into a target host via the Kerberos protocol.
In User Name, provide the username for the user account on the remote server. For example, if you want to SSH into an AWS EC2 instance, the username would be ec2-user.
In Select or create a SSH Key, click Create or Select a Secret.
You can do one of the following: 3. Click Create a new secret. You can create an Encrypted File Secret 4. Click Select an existing secret. You can add an existing Encrypted File Secret present at your Project, Account or Organization level.
If you are editing an existing SSH Key File, you will not be able to edit the existing inline key that you have entered earlier. Instead, you should select an existing file or create a new Encrypted SSH key file.
- In Select Encrypted Passphrase, add the SSH key passphrase if one is required. It is not required by default for AWS or many other platforms. Make sure you use a Harness Encrypted Text secret to save the passphrase and refer to it here. Either select an existing secret from the drop-down list or create a new one by clicking Create or Select a Secret. For more information on creating an Encrypted Text Secret, see Add Text Secrets.
- In SSH Port, leave the default 22 or enter a different port if needed.
- Click Save and Continue.
- In Host Name, enter the hostname of the remote server you want to SSH into. For example, if it is an AWS EC2 instance, it will be something like,
ec2-76-939-110-125.us-west-1.compute.amazonaws.com
. - Click Test Connection. If the test is unsuccessful, you might see an error stating that no Harness Delegate could reach the host, or that a credential is invalid. Make sure that your settings are correct and that a Harness Delegate is able to connect to the server.
- When a test is successful, click Submit.
Notes
You can convert your OpenSSH key to a PEM format with:
ssh-keygen -p -m PEM -f your_private_key
This will convert your existing file headers from:
-----BEGIN OPENSSH PRIVATE KEY-----
to
-----BEGIN RSA PRIVATE KEY-----