Questions tagged [net-ssh]

A pure-Ruby implementation of the SSH2 client protocol. It allows you to write programs that invoke and interact with processes on remote servers, via SSH2.

A pure-Ruby implementation of the SSH2 client protocol. It allows you to write programs that invoke and interact with processes on remote servers, via SSH2. http://net-ssh.rubyforge.org/ssh/v2/api/

207 questions
2
votes
1 answer

Passphrase Key-based authenication with net-sftp in Ruby

Based on question Key based authenication with net-sftp in Ruby, I can SFTP with key-based authentication using the following: Net::SFTP.start(host, "user", keys:['~/.ssh/my_key']) do |sftp| sftp.upload! "/local/file.tgz",…
MrDuk
  • 16,578
  • 18
  • 74
  • 133
2
votes
1 answer

How do I cancel a long running Ruby Net::SSH command

If I kick off a long running command like a database dump using exec, how would I go about canceling that command on the remote host if, for example, the user start mashing Control-C to kill the script. In my testing it seems like even if you…
Josh Rickard
  • 1,593
  • 2
  • 16
  • 29
2
votes
1 answer

Net-ssh session timeout

I am using Net-sshto launch a remote Python script. The Ruby script seems to hang and never complete when the Python script takes a long time to execute (around 20 minutes). I have tested the script by running it directly and it completes without…
Rojj
  • 1,170
  • 1
  • 12
  • 32
2
votes
2 answers

How to run the commands in Ruby as a root

I am using net/ssh gem in Ruby. By the following code I can enter into the server from my local machine. But I want to execute the commands on the server by entering as a ROOT. Normally, I enter into the server as a ROOT by the command sudo su…
user1642224
  • 61
  • 14
2
votes
3 answers

Executing a Ruby method inside a Net::SSH session

Ruby 1.9.3, net-ssh 2.9.2 I am working on a project, in which I need to diff the same directory (and its subdirectories) on two different servers (local and remote). From there, I need to copy the newest/recently modified files to the correct…
onebree
  • 1,853
  • 1
  • 17
  • 44
2
votes
1 answer

Executing Password Change over Ruby Net-SSH

I am looking to execute a password change over Net-ssh and this code seems to hang: Net::SSH.start(server_ip, "user", :verbose => :debug ) do |session| session.process.popen3("ls") do |input, output, error| ["old_pass","test", "test"].each…
tesserakt
  • 3,231
  • 4
  • 27
  • 40
2
votes
1 answer

Ruby/NetSSH try username and password only once?

Is there a way to fail immediately after trying a username and password sequence with Net::SSH.start()? I am looking to test to see if credentials work then stop afterwards, here is the code that I have output = 0 Net::SSH.start('host', 'user',…
ehime
  • 8,025
  • 14
  • 51
  • 110
2
votes
1 answer

Speed up ruby ssh handshake

I'm in ruby on rails and using the net-ssh gem to ssh into another machine, run some scripts, get the output of the scripts back into rails, then serve that output on my site. This will need to happen a lot, in fact it is the core of my site. The…
bumpkin
  • 3,321
  • 4
  • 25
  • 32
2
votes
1 answer

How to allocate a remote pty using Net::SSH::Connection::Channel#request_pty

I am building a raspberry-pi clients manager, where those clients are connected to a server through SSH reverse tunnels. I am using for this the Sinatra framework and the net-ssh library. For single commands this is obvious, I used server-side…
Nafaa Boutefer
  • 2,169
  • 19
  • 26
2
votes
0 answers

Run local script on remote server with ruby net-ssh

Currently I have this for running scripts on remote servers: require 'rubygems' require 'net/ssh' require 'optparse' USER = 'user1' PASS = 'happy123' HOST = 'server1' Net::SSH.start( HOST, USER, :password => PASS ) do|ssh| results =…
cashman04
  • 1,134
  • 2
  • 13
  • 27
2
votes
1 answer

Net::SSH : How easy it is to create a ruby SSH server it can interact with?

I have this ruby library which establishes telnet or ssh connections to remote devices. All seems to work. The testing framework (which works for telnet) defines device simulators which bind to a port, and the test connection bind to that same port.…
ChuckE
  • 5,610
  • 4
  • 31
  • 59
2
votes
1 answer

Ruby net/ssh hangs with specific host

I have an issue where if I'm trying to create a ssh connection to a specific host, the connection hangs without timing out. I have tried connecting to this host from the same machine from outside the rails console and it works so I'm assuming this…
Oktav
  • 2,143
  • 2
  • 20
  • 33
2
votes
1 answer

ruby running commands on a remote machine

I'm trying to run commands remotely with ruby's net ssh. I need the output as well as the exit code. There are other stackoverflow threads on this topic but the accepted solutions do not work. Some people suggested using net-ssh-shell gem but as I…
max
  • 9,708
  • 15
  • 89
  • 144
2
votes
1 answer

Ruby net-ssh: How to authenticate with pubkey using a gateway

I am trying to run a script in several machines I have at work, to gather some information about them, such as which OS they're running, what services run on them, some configurations, etc. I have a machine on which I log before ssh-ing to any of…
malvim
  • 1,194
  • 1
  • 8
  • 17
2
votes
3 answers

Local installation of ruby / rubygems with no root access

I have a machine at work from wich I'd like to run a script that gathers some information about other machines. I want to do it in Ruby, since it's what I know best, but I've ran into some problems, all apparently due to the same reason: I don't…
malvim
  • 1,194
  • 1
  • 8
  • 17