Net::SSH to login into a server with a public key

Hi,
I have a remote server B which can only accessed via server A through a
public key.

Is there a way to do this in net/ssh ?

I have started an SSH session for A

Net::SSH.start(“ServerA”,“username”,:password=>“xyz”) do |ssh|
#is there a way to now login into B?
#In putty I just do: ssh B and I am in
end

thanks.

Is there a way to do this in net/ssh ?

Take a look at Net::SSH::Gateway:

And here’s a wrapper that takes care of the details (which is really
useful if the environment gets more complex):

Delano

On 15.05.2009, at 21:09, Ad Ad wrote:

Hi,
I have a remote server B which can only accessed via server A
through a
public key.

Is there a way to do this in net/ssh ?

Yes it’s very simple.
http://net-ssh.rubyforge.org/ssh/v2/api/index.html

I have started an SSH session for A

Net::SSH.start(“ServerA”,“username”,:password=>“xyz”) do |ssh|
Net::SSH.start(“ServerA”,“username”,:keys=>[“~/.ssh/id_rsa”]) do |ssh|

#is there a way to now login into B?
#In putty I just do: ssh B and I am in

end

regards, Sandor
Szücs