For years I've been deploying my Rails 3.2.13 app successfully using Capistrano. But just today I ran into the dreaded ArgumentError: Could not parse PKey: no start line
when connecting to the server.
From other posts I gather this is actually an issue with the net-ssh
gem, which Capistrano uses to make the connection. Apparently older versions of net-ssh
aren't compatible with the key files created by more recent versions of OpenSSH. (See here and here for example.)
This diagnosis is supported by (a) the fact I can still SSH into my server from the command line, and (b) the following little irb
session:
irb(main):006:0> require 'net/ssh'
=> true
irb(main):007:0> Net::SSH::KeyFactory.load_private_key('~/.ssh/id_rsa')
ArgumentError: Could not parse PKey: no start line
I guess I updated my private key file recently when I changed my password, and now it's incompatible with my version of net-ssh
(v2.7.0).
I can't upgrade net-ssh
since I'm stuck with Ruby 1.9.3.
Is there maybe a way to get back to an old/compatible version of the private key file? Or some other solution perhaps?
Solved it by running:
ssh-keygen -p -m PEM
and then following the prompts to "reset" the password for my private key.
Adding the -m PEM
option gave me back the old-style ~/.ssh/id_rsa
file I needed for compatibility with my old version of net-ssh
.