delano / rye

Safe, parallel access to Unix shells from Ruby
http://delano.github.com/rye
MIT License
235 stars 32 forks source link

problem when using several ssh keys via hop #37

Open rrepen opened 11 years ago

rrepen commented 11 years ago

In the following example I am just running a simple command on hostB via hostA. The SSH keys are already in place and this works fine from the bash prompt, but when I use Rye and setup the gw and the box without the password it fails and Rye asks for the pasword.

This is due to the fact that the ssh keys from localhost to hostA is different from the ssh key hostA to hostB. In the last example I copy over the ssh key hostA->hostB back to localhost in the private_key and add this key to the key list and then it works fine.

Is there some configuration I miss in Rye to do that?

I think Rye should be able to manage that and avoid the user to copy over the ssh key. In case of several hop this could be a real nigthmare.


user1:~> ssh hostA ssh hostB "uname -a" Linux hostB 2.6.32.45-0.3.2_1 #1 SMP Wed Feb 8 05:03:48 UTC 2012 x86_64 x86_64 x86_64 GNU/Linux

irb(main):001:0> require 'rye' => true irb(main):002:0> gw=Rye::Hop.new("hostA") => #<Rye::Hop:hostA name=hostA cwd= umask= env="" via="" opts={:port=>nil, :keys=>["/home/user1/.ssh/id_dsa"]} keys=["/home/user1/.ssh/id_dsa"]> irb(main):003:0> box=Rye::Box.new("hostB",:via=>gw) => #<Rye::Box:hostB name=hostB cwd= umask= env="" safe=true opts={:port=>nil, :keys=>["/home/user1/.ssh/id_dsa"], :paranoid=>true} keys=["/home/user1/.ssh/id_dsa"]> irb(main):004:0> r=box.send("uname","-a") Password:
...

user1:~> mkdir private_keys user1:~> scp hostA:.ssh/id_dsa* ./private_keys

irb(main):001:0> require 'rye' => true irb(main):002:0> gw=Rye::Hop.new("hostA") => #<Rye::Hop:hostA name=hostA cwd= umask= env="" via="" opts={:port=>nil, :keys=>["/home/user1/.ssh/id_dsa"]} keys=["/home/user1/.ssh/id_dsa"]> irb(main):003:0> box=Rye::Box.new("hostB",:via=>gw) => #<Rye::Box:hostB name=hostB cwd= umask= env="" safe=true opts={:port=>nil, :keys=>["/home/user1/.ssh/id_dsa"], :paranoid=>true} keys=["/home/user1/.ssh/id_dsa"]> irb(main):004:0> box.add_key("./private_keys/id_dsa") => #<Rye::Box:hostB name=hostB cwd= umask= env="" safe=true opts={:port=>nil, :keys=>["/home/user1/.ssh/id_dsa", "./private_keys/id_dsa"], :paranoid=>true} keys=["/home/user1/.ssh/id_dsa"]> irb(main):009:0> r=box.send("uname","-a") => [Linux hostB 2.6.32.45-0.3.2_1 #1 SMP Wed Feb 8 05:03:48 UTC 2012 x86_64 x86_64 x86_64 GNU/Linux, , 0, ] irb(main):010:0>