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


#1

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.


#2

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

Take a look at Net::SSH::Gateway:
http://github.com/jamis/net-ssh-gateway/tree/master

And here’s a wrapper that takes care of the details (which is really
useful if the environment gets more complex):
http://github.com/Narnach/simple_gate

Delano


#3

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