net-ssh

Get Live logs in front end on rails application

故事扮演 提交于 2020-03-21 16:01:56
问题 Here in the rails 3.x app,I am using net::ssh and running some commands to remote pc.I would like to display the live logs to the user's browser.like,If two commands are running in net::ssh to execute i.e echo "Hello" , echo "Bye" is passed then "Hello" should be displayed in the browser immediately finishing after its execution.Here is the code I am using for ssh connection and running commands in ruby on rails application Net::SSH.start( @servers['local'] , @machine_name, :password =>

Get Live logs in front end on rails application

丶灬走出姿态 提交于 2020-03-21 16:01:02
问题 Here in the rails 3.x app,I am using net::ssh and running some commands to remote pc.I would like to display the live logs to the user's browser.like,If two commands are running in net::ssh to execute i.e echo "Hello" , echo "Bye" is passed then "Hello" should be displayed in the browser immediately finishing after its execution.Here is the code I am using for ssh connection and running commands in ruby on rails application Net::SSH.start( @servers['local'] , @machine_name, :password =>

Net-ssh session timeout

送分小仙女□ 提交于 2020-01-04 06:45:10
问题 I am using Net-ssh to 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 any error. Also everything works fine when the script is executed in a shorter amount of time. This is an extract of the code I am using: (0..(@number_of_vms - 1)).each_with_index do |vm, i| threads << Thread.new do Net::SSH.start('ip-address-vm',

How to get exit status with Ruby's Net::SSH library?

狂风中的少年 提交于 2019-12-31 08:15:27
问题 I have a snippet of code, simply trying to execute a script on a remote server, in the event that it fails, I'd like to make a follow-up call, imagine this: require 'rubygems' require 'net/ssh' require 'etc' server = 'localhost' Net::SSH.start(server, Etc.getlogin) do |ssh| puts (ssh.exec("true") ? 'Exit Success' : "Exit Failure") puts (ssh.exec("false") ? 'Exit Success' : "Exit Failure") end I would expect (ignoring that stdout and stderr are printed in my contrived example) - but first line

Generate SSH Keypairs (private/public) without ssh-keygen

拟墨画扇 提交于 2019-12-30 02:40:06
问题 I'm working on a Ruby/Rack application that needs to generate SSH keypairs. As much as I'd like to call ssh-keygen from the application, I can't because it's designed to run on Heroku and they don't support calling that command. I've been able to get private/public RSA keys using OpenSSL in the Ruby standard library doing the following: key = OpenSSL::PKey::RSA.generate(2048) # => -----BEGIN RSA PRIVATE KEY----- .... key.public_key # => -----BEGIN RSA PUBLIC KEY----- .... Unfortunately an RSA

Using net/ssh/gateway to establish ssh tunnel to mysql

岁酱吖の 提交于 2019-12-24 05:59:16
问题 I'm attempting to establish a tunnel to a remote server via ssh, and then use the forwarded port to access MySQL. I'm using it currently like this $gateway = Net::SSH::Gateway.new('target.server', 'user') def with_gateway $gateway.open("target.server", 3306) do |port| yield port end end Which in my mind would be similar to this... `ssh -L #{port}:localhost:3306 -N user@target.server` Then when I try to use it and do something like this. with_gateway do |port| puts `mysql -u user -ppass -h 127

Using net/ssh/gateway to establish ssh tunnel to mysql

懵懂的女人 提交于 2019-12-24 05:58:13
问题 I'm attempting to establish a tunnel to a remote server via ssh, and then use the forwarded port to access MySQL. I'm using it currently like this $gateway = Net::SSH::Gateway.new('target.server', 'user') def with_gateway $gateway.open("target.server", 3306) do |port| yield port end end Which in my mind would be similar to this... `ssh -L #{port}:localhost:3306 -N user@target.server` Then when I try to use it and do something like this. with_gateway do |port| puts `mysql -u user -ppass -h 127

Ruby on rails - cannot load such file — net/ssh

点点圈 提交于 2019-12-22 03:26:30
问题 I've been struggling on this for a few days now.. When I try to call a method in a helper from a view to do ssh, it throws that error. "This error occurred while loading the following files: net/ssh" But when I copy the code into a test.rb file and execute it from prompt ruby test.rb it connects flawlessly. What could be the problem ? I tried on another computer and same result. Thank you very much this is like the last step before I can complete my project! Regards, application_helper.rb :

Ruby on rails - cannot load such file — net/ssh

我们两清 提交于 2019-12-22 03:25:15
问题 I've been struggling on this for a few days now.. When I try to call a method in a helper from a view to do ssh, it throws that error. "This error occurred while loading the following files: net/ssh" But when I copy the code into a test.rb file and execute it from prompt ruby test.rb it connects flawlessly. What could be the problem ? I tried on another computer and same result. Thank you very much this is like the last step before I can complete my project! Regards, application_helper.rb :

ruby net-ssh login shell

自作多情 提交于 2019-12-19 03:07:07
问题 Is there any way i can get a login shell in ruby using net-ssh? Is that even possible? By login shell i mean the ones the source /etc/profile.. 回答1: Net-SSH is too low level to simply provide this up front (the way it is now, anyways). You can check out Net-SSH-Shell which builds upon Net-SSH to add login shell functionality: https://github.com/mitchellh/net-ssh-shell The implementation is solid and works, however I found its not too useful since you can't specifically extract things like