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.
5d796bf72614c104dec185427c90c8de?d=identicon&s=25 Ad Ad (adad)
on 2009-05-15 21: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.
601fb9606dd1479c15261c460625590a?d=identicon&s=25 Delano Mandelbaum (Guest)
on 2009-05-15 22: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
Cb6bbc826cd7d9238a2fae344958f7ec?d=identicon&s=25 Sandor Szücs (Guest)
on 2009-05-17 10: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.