SSH keys

SSH keys are one of the most secure and convenient authentication methods. A common use case can be cloning a repository locally or connecting with a remote server. In Buddy’s pipelines, you can use the keys for the following things:

  1. Authenticate file upload in the SFTP action
  2. Authenticate script execution on the server in the SSH action
  3. Authenticate the download of private modules and dependencies in build actions

You can add the key individually to each of your actions, but a more straightforward method is to add it as an environment variable that can be used in the input fields across the whole workspace.

Defining SSH keys

To use a key in one of the actions, you need to add them to environment variables by entering the ${KEY_NAME} and value. You can define keys for the whole workspace, a project, or a single pipeline:

  • Workspace: go to the workspace Preferences and switch to the Environment Variables tab.
  • Project: go to Project Options and choose the Environment Variables tab.
  • Pipeline: go the pipeline that you want to use the key in and head to the Environment Variables tab.

Adding SSH key as workspace environment variableAdding SSH key as workspace environment variable

Using SSH keys

  1. To use the key in an SFTP or SSH action, just provide the key value in the key input: Using SSH key as an environment variable in SFTP actionUsing SSH key as an environment variable in SFTP action
  2. In build actions all defined keys are available in the ~/.ssh directory.

    • If you want Buddy to use your key in SSH connections by default, name it id_rsa
    • If your build requires more than one key, add ~/.ssh/config to the pipeline’s filesystem and define which key is used for what host, eg.:

        Host github.com
            IdentityFile ~/.ssh/github.key

      Location of pipeline filesystemLocation of pipeline filesystem

Last modified on April 26, 2022

Questions?

Not sure how to configure a pipeline for your process? Reach out on the live-chat or contact support

Get Started

Sign up for free and deploy your project in less than 10 minutes.