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

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Ad A. (Guest)
on 2009-05-15 23:09
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.
Delano Mandelbaum (Guest)
on 2009-05-16 00:10
(Received via mailing list)
> 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
Sandor Szücs (Guest)
on 2009-05-17 12:38
(Received via mailing list)
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
This topic is locked and can not be replied to.