SSH keys

SSH keys are one of the most secure and convenient authentication methods. A common use case involves, for example, cloning a repository locally or connecting to 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 server script execution in the SSH action
  3. Authenticate the download of private modules and dependencies in container 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 it 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 Variables, Keys & Assets tab in the left menu.
  • Project: go to the Variables, Keys & Assets tab in the left menu.
  • Pipeline: go to the pipeline that you want to use the key in and switch to the Variables tab.

Image loading...Adding SSH key as workspace environment variable

Using SSH keys

  1. To use the key in an SFTP or SSH action, you just need to provide the key value in the SSH key input:

Image loading...Using SSH key as an environment variable in SFTP action

  1. In container actions, all defined keys are available in the ~/.ssh directory of the pipeline filesystem:
  • 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, for example:

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

Image loading...Pipeline filesystem view

Last modified on Sep 23, 2024