Skip to content
GitLab
  • Menu
Projects Groups Snippets
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
    • Switch to GitLab Next
  • Sign in / Register
  • S ssh-private-key
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
    • Locked Files
  • Issues 9
    • Issues 9
    • List
    • Boards
    • Service Desk
    • Milestones
    • Iterations
    • Requirements
  • Merge requests 7
    • Merge requests 7
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
    • Test Cases
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Code review
    • Insights
    • Issue
    • Repository
  • Wiki
    • Wiki
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • GitLab-examples
  • ssh-private-key
  • Merge requests
  • !21

Introducing the way to use an encrypted ssh-key with new variable SSH_PASSPHRASE.

  • Review changes

  • Download
  • Email patches
  • Plain diff
Open Bas Meijer requested to merge bbaassssiiee/ssh-private-key:security/encrypted-key into master Apr 23, 2021
  • Overview 2
  • Commits 2
  • Pipelines 2
  • Changes 1

This pull-request adds functionality to .gitlab-ci.yml that allows the use of an encrypted ssh-key. You need to create a variable SSH_PASSPHRASE, which is used when adding the private key to ssh-agent.

The ENVIRONMENT section of the manual page of ssh-add explains how ssh-add can be scripted. This is done using 2 variables which are set in the before_script: section. Setting DISPLAY=None drops the need for X11. SSH_ASKPASS is an executable called by ssh-add when it is instructed to read from stdin.

Therefore SSH_ASKPASS is a simple shell script that simply prints the value of the variable SSH_PASSPHRASE to stdout, so we can pipe it into ssh-add.

The pipeline in this project seems to have a config issue, my fork runs fine:

https://gitlab.com/bbaassssiiee/ssh-private-key/-/jobs/1207216682

image

Fix for #20 and #7.

Edited Apr 23, 2021 by Bas Meijer
Assignee
Assign to
Reviewer
Request review from
Time tracking
Source branch: security/encrypted-key