Skip to content

Our step-by-step, from the ground up walk-through on setting up a Private SSH key in Codeship Pro

Notifications You must be signed in to change notification settings

codeship-library/setting-ssh-private-key-in-pro

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

setting-ssh-private-key-in-pro

Initialize Project

  • Clone this repo
  • Initialize as a new git repo -- rm -rf .git && git init && git add . && git commit -m 'first commit'

Selecting a Private Key

Option A -- Generate a public and private ssh key

  • To generate a codeship_deploy_key and codeship_deploy_key.pub file, modify the following command with your own email address and run our ssh-helper tool in your project directory:
docker run -it --rm -v $(pwd):/keys/ codeship/ssh-helper generate "<YOUR_EMAIL>"

Option B -- Use your own pre-existing private ssh key

  • Copy file to project directory and rename to codeship_deploy_key (must be a key that does not require a passphrase)

Prepare the Environment Variables file

  • Run the following command from the project directory:
docker run -it --rm -v $(pwd):/keys/ codeship/ssh-helper prepare
  • Process will store PRIVATE_SSH_KEY value as a one liner entry into the codeship.env file. If codeship.env already exists, the PRIVATE_SSH_KEY entry will be appended to it.
  • Remove the codeship_deploy_key (!)
  • Add codeship.env to your .gitignore file (!)

Encrypt the Environment Variables file

  • Install our jet cli tool on your local machine
  • Setup your repository on your SCM of choice
  • Grab the git url of the repository and create a Codeship Pro project
  • From your Codeship 'Project Settings' > 'General' page, scroll down to AES key section and click 'Download Key'
  • Move downloaded key to your project directory and rename to codeship.aes
  • Add codeship.aes to your .gitignore file (!)
  • Add any additional environment variables to the codeship.env file
  • Run jet encrypt codeship.env codeship.env.encrypted
  • The codeship.env.encrypted will be safe to check into your git repository

Add public key to your SCM of choice

Run jet steps

  • Run jet steps
  • Steps should pass, demonstrating that id_rsa is now accessible to the main app via volumes
  • Be sure to modify the volume pathing to .ssh in the codeship-services.yml if the container user is not root
  • Add .ssh directory to your .gitignore file (!)

About

Our step-by-step, from the ground up walk-through on setting up a Private SSH key in Codeship Pro

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published