Install SSH Key task

Azure Pipelines

Use this task in a pipeline to install an SSH key prior to a build or release step.

YAML snippet

# Install SSH Key
# Install an SSH key prior to a build or release
- task: InstallSSHKey@0
    #sshPassphrase: # Optional


Known Hosts Entry(Required) The entry for this SSH key for the known_hosts file.
SSH Public Key(Required) The contents of the public SSH key.
SSH Passphrase(Optional) The passphrase for the SSH key, if any.
SSH Key(Required) Select the SSH key that was uploaded to Secure Files to install on the agent.
Control options

Example setup using GitHub

  1. 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. and mykey).
  2. Upload the (public) SSH key to GitHub (see GitHub's documentation for help).
  3. On a local computer, add the private SSH key by running ssh-add ~/.ssh/mykey, replacing ~/.ssh/mykey with the path to your private key file.
  4. Clone the repository to the local computer (git clone
  5. While cloning the repository, you will be asked whether to trust GitHub. Accepting will add the SSH key to your known_hosts file.
  6. Open your known_hosts file (~/.ssh/known_hosts or 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', 'SSH Public Key', and 'SSH Passphrase' - Enter these values that were created in step 1

Open source

This task is open source on GitHub. Feedback and contributions are welcome.