How to configure capistrano to use local rsa key instead of ssh agent

925 Views Asked by At

I used capistrano to deploy my project using my local rsa key located at ~/.ssh/id_rsa. This always worked as expected.

Now I installed the development environment on a new computer, and now when I run cap ... deploy, I get this error:

OpenSSH keys only supported if ED25519 is available (NotImplementedError) net-ssh requires the following gems for ed25519 support:

  • ed25519 (>= 1.2, < 2.0)
  • bcrypt_pbkdf (>= 1.0, < 2.0)

I found plenty of questions about this while googling. Most suggest to run ssh-add ~/.ssh/id_rsa to add the key to the ssh agent, some suggest to install the two listed gems and use a ed25519 key.

I understand from there, that capistrano is looking for a key stored in the ssh agent, and then falls back to using an ed25519 key. What I need is that capistrano simply is using the local ssh key located at ~/.ssh/id_rsa.

I didn't find how to tell capistrano to use the local ssh key ~/.ssh/id_rsa instead of the ssh agent.

Notes

I am using cygwin on Windows, and the installation of a permanent ssh agent is tricky. I found lengthy instructions, but did not get it to work.

As a workaround, I run these commands before cap ... deploy

eval "$(ssh-agent -s)"
ssh-add ~/.ssh/id_rsa

Long question short

How can I configure capistrano or ssh that way that cap ... deploy picks the RSA key at ~/.ssh/id_rsa to connect to the remote server ?

1

There are 1 best solutions below

1
anonymus_rex On

This seems to be a SSH issue instead a Capistrano one. First some explanations..

ssh-agent stores securely your decrypted keys on memory and "there is no reasonable and safe way to preserve the decrypted keys among reboots/re-logins"

ssh-add just adds these keys to your agent

With that said, it seems that your operative system isn't loading your keys on your ssh agent automatically when it boot, so the solution is to automate this task and set it up to run when you starts your session.

I'm not a Windows user and I don't have any way to test this answer, but hope this solve your problem.

  1. On desktop, right click and "New" > "Shortcut"
  2. When it asks for "What item would you like to create a shortcut for?", enter this: "start-ssh-agent" (with quotation marks included). Then click "Next"
  3. On "What would you like to name the shortcut?" enter any name, for example: autoloadssh.exe (must be an executable). Click "Save"
  4. Copy this shortcut and paste it on your startup folder located at "C:\Users[YOUR_USER]\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup"
  5. Reboot your system and after load you should be able to run "cap ... deploy"

Take a look to this thread.