Use SSH KEY from ENV Var

Viewed 69

I need to run some git commands from a ruby on rails application. I have the ssh private key (password protected) stored in an env var. How can I run git commands using the ssh keys from the env var without dumping it on the filesystem?

2 Answers

After some digging I found a solution using openssl:

echo "#{private_key}" | openssl rsa -passin pass:$PRIVATE_KEY_PASSPHRASE | ssh-add -

Related