Strange issue with SSH keys

2,576 views
Skip to first unread message

will

unread,
Aug 18, 2009, 2:02:33 PM8/18/09
to Capistrano
Hi,

I currently have a issue but I am not really sure what is causing it

when I try and deploy I get the following

(OpenSSL::PKey::PKeyError: not a private key (/Users/user/.ssh/
id_rsa.pub))

It says it isn't a private key? which obviously isn't as you can see
its a public key

what I can't understand I can use IRB with Net:SSH fine and also from
ssh client and another Mac can also use the same deploy script no
problems so I am really sure where the issue exists?

The OS I created the keys on is OSX and the servers are running
Ubuntu

Any pointers appreciated,

Thanks,
Will

Jonathan Weiss

unread,
Aug 18, 2009, 3:13:23 PM8/18/09
to capis...@googlegroups.com
> (OpenSSL::PKey::PKeyError: not a private key (/Users/user/.ssh/
> id_rsa.pub))

How do you define the ssh_keys in deploy.rb? You only need to point to
the private key, not the public key.

Jonathan

will

unread,
Aug 19, 2009, 6:13:29 AM8/19/09
to Capistrano
Yeah my mistake I defined the Public key after messing around with it,
if I specify the private key though I get the following

** [server1 :: out] Error reading response length from authentication
socket.
** [server1 :: out] Error reading response length from authentication
socket.
** [server1 :: out] Error reading response length from authentication
socket.
** [server1:: out] Permission denied (publickey).
** [server1 :: out] fatal: The remote end hung up unexpectedly
** [server1 :: out] Permission denied (publickey).
** [server1 :: out] fatal: The remote end hung up unexpectedly
** [server :: out] Permission denied (publickey).
** [server :: out] fatal: The remote end hung up unexpectedly

I specify the key in deploy.rb like so

ssh_options[:keys] = %w(/Users/user/.ssh/id_rsa)

Thanks
Message has been deleted
Message has been deleted
Message has been deleted

will

unread,
Aug 20, 2009, 6:04:43 AM8/20/09
to Capistrano
Any ideas? Its driving me insane, I just can't understand why it would
would in IRB and ssh client using the same key but not in Capistrano

On Aug 19, 11:13 am, will <will.p...@gmail.com> wrote:
> Yeah my mistake I defined the Public key after messing around with it,
> if I specify the private key though I get the following
>
>  ** [server1 :: out] Error reading response length from authentication
> socket.
>  ** [server1 :: out] Error reading response length from authentication
> socket.
>  ** [server1 :: out] Error reading response length from authentication
> socket.
>  ** [server1:: out] Permission denied (publickey).
>  ** [server1 :: out] fatal: The remote end hung up unexpectedly
>  ** [server1 :: out] Permission denied (publickey).
>  ** [server1 :: out] fatal: The remote end hung up unexpectedly
>  ** [server :: out] Permission denied (publickey).
>  ** [server :: out] fatal: The remote end hung up unexpectedly
>
> I specify the key in deploy.rb like so
>
> ssh_options[:keys] = %w(/Users/user/.ssh/id_rsa)
>
> Thanks
>
> On Aug 18, 8:13 pm, Jonathan Weiss <j...@innerewut.de> wrote:
>

Lee Hambley

unread,
Aug 20, 2009, 6:10:19 AM8/20/09
to capis...@googlegroups.com
Will,

Try not defining the key in your Ruby code, but instead in ~/.ssh/config (it's more useful in there anyway, and Cap (well, Net::SSH) honours that)

Let us know?

-- Lee Hambley

Twitter: @leehambley
Blog: http://lee.hambley.name/
Working with Rails: http://is.gd/1s5W1


2009/8/20 will <will...@gmail.com>

will

unread,
Aug 20, 2009, 6:19:25 AM8/20/09
to Capistrano
Any ideas? Its driving me insane, I just can't understand why it would
would in IRB and ssh client using the same key but not in Capistrano

On Aug 19, 11:13 am, will <will.p...@gmail.com> wrote:
> Yeah my mistake I defined the Public key after messing around with it,
> if I specify the private key though I get the following
>
>  ** [server1 :: out] Error reading response length from authentication
> socket.
>  ** [server1 :: out] Error reading response length from authentication
> socket.
>  ** [server1 :: out] Error reading response length from authentication
> socket.
>  ** [server1:: out] Permission denied (publickey).
>  ** [server1 :: out] fatal: The remote end hung up unexpectedly
>  ** [server1 :: out] Permission denied (publickey).
>  ** [server1 :: out] fatal: The remote end hung up unexpectedly
>  ** [server :: out] Permission denied (publickey).
>  ** [server :: out] fatal: The remote end hung up unexpectedly
>
> I specify the key in deploy.rb like so
>
> ssh_options[:keys] = %w(/Users/user/.ssh/id_rsa)
>
> Thanks
>
> On Aug 18, 8:13 pm, Jonathan Weiss <j...@innerewut.de> wrote:
>

will

unread,
Aug 20, 2009, 6:30:13 AM8/20/09
to Capistrano
I specified it like so

IdentityFile ~/.ssh/id_rsa

in .ssh/config but I am still getting the same error

On Aug 20, 11:10 am, Lee Hambley <lee.hamb...@gmail.com> wrote:
> Will,
> Try not defining the key in your Ruby code, but instead in ~/.ssh/config
> (it's more useful in there anyway, and Cap (well, Net::SSH) honours that)
>
> Let us know?
>
> -- Lee Hambley
>
> Twitter: @leehambley
> Blog:http://lee.hambley.name/
> Working with Rails:http://is.gd/1s5W1
>
> 2009/8/20 will <will.p...@gmail.com>

Lee Hambley

unread,
Aug 20, 2009, 6:35:12 AM8/20/09
to capis...@googlegroups.com
can you paste your config file, is that particular line under a Host entry ?

eg.

Host *
  ForwardAgent yes
  ForwardX11 no
  User leeh
  IdentityFile ~/.ssh/id_rsa

(indentation matters in that file)

-- Lee Hambley

Twitter: @leehambley
Blog: http://lee.hambley.name/
Working with Rails: http://is.gd/1s5W1


2009/8/20 will <will...@gmail.com>
Message has been deleted

Lee Hambley

unread,
Aug 20, 2009, 6:47:25 AM8/20/09
to capis...@googlegroups.com
Try it like I did mine?

-- Lee Hambley

Twitter: @leehambley
Blog: http://lee.hambley.name/
Working with Rails: http://is.gd/1s5W1


2009/8/20 will <will...@gmail.com>

I specified it like so

 IdentityFile ~/.ssh/id_rsa

in .ssh/config but I am still getting the same error

On Aug 20, 11:10 am, Lee Hambley <lee.hamb...@gmail.com> wrote:
> Will,
> Try not defining the key in your Ruby code, but instead in ~/.ssh/config
> (it's more useful in there anyway, and Cap (well, Net::SSH) honours that)
>
> Let us know?
>
> -- Lee Hambley
>
> Twitter: @leehambley
> Blog:http://lee.hambley.name/
> Working with Rails:http://is.gd/1s5W1
>
> 2009/8/20 will <will.p...@gmail.com>

will

unread,
Aug 20, 2009, 6:49:09 AM8/20/09
to Capistrano
Just an adapted ssh_config from /etc

Host *
ForwardAgent yes
IdentityFile ~/.ssh/identity
IdentityFile ~/.ssh/id_rsa
IdentityFile ~/.ssh/id_dsa
User willpink
Port 22

Thanks


On Aug 20, 11:35 am, Lee Hambley <lee.hamb...@gmail.com> wrote:
> can you paste your config file, is that particular line under a Host entry ?
> eg.
>
> Host *
>   ForwardAgent yes
>   ForwardX11 no
>   User leeh
>   IdentityFile ~/.ssh/id_rsa
>
> (indentation matters in that file)
>
> -- Lee Hambley
>
> Twitter: @leehambley
> Blog:http://lee.hambley.name/
> Working with Rails:http://is.gd/1s5W1
>
> 2009/8/20 will <will.p...@gmail.com>

will

unread,
Aug 20, 2009, 6:52:25 AM8/20/09
to Capistrano
Just an adapted ssh_config from /etc

Host *
ForwardAgent yes
IdentityFile ~/.ssh/identity
IdentityFile ~/.ssh/id_rsa
IdentityFile ~/.ssh/id_dsa
User willpink
Port 22

Thanks


On Aug 20, 11:35 am, Lee Hambley <lee.hamb...@gmail.com> wrote:
> can you paste your config file, is that particular line under a Host entry ?
> eg.
>
> Host *
>   ForwardAgent yes
>   ForwardX11 no
>   User leeh
>   IdentityFile ~/.ssh/id_rsa
>
> (indentation matters in that file)
>
> -- Lee Hambley
>
> Twitter: @leehambley
> Blog:http://lee.hambley.name/
> Working with Rails:http://is.gd/1s5W1
>
> 2009/8/20 will <will.p...@gmail.com>

will

unread,
Aug 20, 2009, 6:53:54 AM8/20/09
to Capistrano
Sorry not sure what happened there seemed to of duplicated my posts
Message has been deleted
Message has been deleted

will

unread,
Aug 20, 2009, 8:59:52 AM8/20/09
to Capistrano
well I recreated the keys on the client and created a passphrase for
them I no longer get the permission denied but I do get the following

servers: ["server1"]
Enter passphrase for /Users/willpink/.ssh/id_rsa:
[server1] executing command
** [server1 :: out] Error reading response length from authentication
socket.
** [server1 :: out] Tunnel device open failed.
** Could not request tunnel forwarding.
command finished

but I have specified tunneling in the ssh config and others can deploy
to this server fine so I don't believe it is an issue with the server

piedpyper

unread,
Aug 25, 2009, 1:01:31 PM8/25/09
to Capistrano
I was having the identical problem and then I realized it was because
my ssh-agent was not running

ssh-agent
ssh-add

is all I had to do to get myself going
Reply all
Reply to author
Forward
0 new messages