Install SSH Key task
Use this task in a pipeline to install an SSH key prior to a build or release step.
# Install SSH key # Install an SSH key prior to a build or deployment - task: InstallSSHKey@0 inputs: knownHostsEntry: sshPublicKey: #sshPassphrase: # Optional sshKeySecureFile:
|Known Hosts Entry||(Required) The entry for this SSH key for the known_hosts file.|
|SSH Public Key||(Optional) The contents of the public SSH key.|
|SSH Passphrase||(Optional) The passphrase for the SSH key, if any.|
|SSH Key (Secure File)||(Required) Select the SSH key that was uploaded to |
Example setup using GitHub
- Create an SSH key using
ssh-keygen- a program that is provided with the SSH package on Linux and macOS and comes with Git for Windows. When you run
ssh-keygen, you will be prompted to provide an SSH passphrase and two files will be created: a public key and a private key (e.g.
- Upload the
mykey.pub(public) SSH key to GitHub (see GitHub's documentation for help).
- On a local computer, add the private SSH key by running
ssh-add ~/.ssh/mykey, replacing
~/.ssh/mykeywith the path to your private key file.
- Clone the repository to the local computer (
git clone firstname.lastname@example.org:myOrganizationName/myRepositoryName.git).
- While cloning the repository, you will be asked whether to trust GitHub. Accepting will add the SSH key to your
- Open your
C:\Users\<username>\.ssh\known_hosts) and copy the line that was added.
You now have all necessary values for the "Install SSH Key" task:
- 'Known Hosts Entry' - Enter the line copied in step 6
- 'SSH Key (Secure File)', 'SSH Public Key', and 'SSH Passphrase' - Enter these values that were created in step 1
This task is open source on GitHub. Feedback and contributions are welcome.