Note that there are some explanatory texts on larger screens.

plurals
  1. POProxy tunnel through multiple systems with Ruby Net::SSH
    primarykey
    data
    text
    <p>I need some suggestions on how to use the Ruby Net::SSH and Net::SCP gem to proxy through several systems in order to execute commands or copy files.</p> <p>It's very similar (if not almost exactly the same) as this previous post I made, using basic ssh from the linux command line.</p> <p><a href="https://stackoverflow.com/questions/10592212/how-to-script-multiple-ssh-and-scp-commands-to-various-systems">How to script multiple ssh and scp commands to various systems</a></p> <p>For example, LOCAL is my local system.</p> <p>System A is a second system connected to LOCAL</p> <p>System B is a third system connected to System A only. Also, System B is configured to only allow access from System A by way of it's ssh key.</p> <p>For normal ssh from the command line, I have my .ssh/config file set up in this way:</p> <pre><code>Host systemA HostName 192.168.0.10 User A-user Host systemB ProxyCommand ssh -e none systemA exec /bin/nc %h %p 2&gt;/dev/null HostName 192.168.0.11 User B-user IdentityFile ~/.ssh/systemA_id_dsa </code></pre> <p>From this point, as long as my pub key is in the authorized_hosts of sysA (let's assume it always will be), and sysA's pub key is in the authorized_hosts sysB (same assumption), the following will work seamlessly:</p> <pre><code>ssh systemB </code></pre> <p>I would like to implement this exact behavior in Ruby. I have some code similar to the following:</p> <pre><code>require 'net/ssh' require 'net/ssh/proxy/command' str = 'ssh -l A-user -i /home/A-user/.ssh/id_dsa -e none 192.168.0.10 exec /bin/nc %h %p 2&gt;/dev/null' proxy = Net::SSH::Proxy::Command.new(str) Net::SSH.start('192.168.0.11', 'B-user', :proxy =&gt; proxy) do |ssh| ssh.exec! "ls -lA" end </code></pre> <p>Unfortunately, this isn't working. I get an authentication failure.</p> <pre><code>~/.rvm/gems/ruby-1.9.3-p327/gems/net-ssh-2.6.2/lib/net/ssh.rb:201:in `start': root (Net::SSH::AuthenticationFailed) </code></pre> <p>What am I missing here?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload