3

I am writing an application that needs to run command on a remote Raspberry PI using a revssh script. revssh is a custom script that implements to some level the Revssh protocol concepts. it uses ssh reverse tunneling to send commands from the server to the clients.

I am using Ruby 2.1, I tried to do this using IO.popen but it does not work, so I tried the following:

# revssh (short for reverse ssh ) enables the execution of remote commands 
# from the server on connected clients, like the 'psu_pi_analytics' here. but it requires
# to enter a root password each time you want to run a command using 'revssh -c' 
IO.popen('revssh -c psu_pi_analytics uname -a', 'w+') do|io|
  io.puts 'password' # enter the password when prompted
  puts io.gets
end

this code work if the command to execute run on the local machine, but not in my case. So any thoughts, or suggestions.

What important here is how to deal with the new connection created by the revssh script using ssh, which is managed in the terminal if the script is run directly from the terminal.

Edit:

By not work I mean it still prompts for the password, even if I puts the password to the io.

Nafaa Boutefer
  • 2,169
  • 19
  • 26
  • I'm not familiar with revssh. What's your OS? – Wayne Conrad Mar 09 '14 at 10:05
  • @WayneConrad , revssh is a custom script that implement to some level the Revssh protocol concepts. You can consider it like an ssh command in the reverse direction, from the server to the client. What important here is how to deal with the new connection created by this script using ssh, which is managed in the terminal if the script is run directly from the terminal. – Nafaa Boutefer Mar 09 '14 at 10:31
  • 1
    Thanks, @Nafaa. That information should probably be added to the question. By the way, what does "not work" mean? What happens? Please click "edit" and add that to your question. – Wayne Conrad Mar 09 '14 at 10:54

1 Answers1

0

You can use an Expect-like library (e.g. RExpect, Expect4r) for interacting with other processes.

Another question related to this: Is there an Expect equivalent gem for Ruby?

Community
  • 1
  • 1
Radu
  • 1,098
  • 1
  • 11
  • 22