net-ssh

Net::SSH works from production rails console, AuthenticationFailed from production webapp

跟風遠走 提交于 2019-12-06 05:19:35
I have a rails app where a user can submit a form and it goes off and connects to a remote server via ssh to call a script. Eventually I plan to use delayed_job or something like that but I can't get it to work in production with even a simple test. The odd thing is, Net::SSH works just fine from the console in production, but it fails with AuthenticationFailed when I submit the form in production. Both the console and the webapp work fine in development. The error: Net::SSH::AuthenticationFailed (my_ssh_username): app/models/branch.rb:69:in `ssh_to_machine' app/controllers/branches_controller

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

旧巷老猫 提交于 2019-12-05 00:47:52
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 : module ApplicationHelper def title(value) unless value.nil? @title = "#{value} | Eucc" end end def

net-ssh and remote environment

风流意气都作罢 提交于 2019-12-03 21:19:37
问题 I want to execute some remote command on my server using net-ssh library. I have the following example: Net::SSH::start(host, user, options = {:keys => '~/.ssh/id_rsa'}) do |ssh| puts ssh.exec!("echo $PATH") ssh.loop end The result is: /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games My problem is that I have not my PATH loaded as it should be. I should also have some RVM paths, and custom paths defining into my .zshrc. How could I change this behavior to let net-ssh to

Can't install chef, gem version conflict with net-ssh net-ssh-multi net-ssh-gateway

陌路散爱 提交于 2019-12-03 14:02:55
问题 Using rvm, and an empty gemset, I get this: $ gem install chef --no-ri --no-rdoc ERROR: While executing gem ... (Gem::DependencyError) Unable to resolve dependencies: chef requires net-ssh (~> 2.2.2); net-ssh-multi requires net-ssh (>= 2.6.5); net-ssh-gateway requires net-ssh (>= 2.6.5) I've tried resolving it by installing earlier versions of net-ssh-gateway and net-ssh-multi, but net-ssh-multi version 1.1 confounds me by installing 1.1.2. 回答1: This is due to an update of net-ssh-multi that

ruby net-ssh calling bash script with interactive prompts

这一生的挚爱 提交于 2019-12-02 16:19:41
问题 I have a problem that I hope you can help me with I’m trying to use ruby to ssh onto a machine and run a bash script, this part is fairly easy but the bash script requires me to entry a username and password interactively and this is where I’m stuck So if I run the script manually I see:- ./run_file.sh Enter username: Enter password: So at the enter Username prompt I have to enter the username etc I’ve got a simple method I use to make the connection and my idea was to pass in an array made

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

白昼怎懂夜的黑 提交于 2019-12-02 14:18:26
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 should exit with 0 which I would expect Ruby would interperate as false and display "Exit Failure"

ruby net-ssh login shell

怎甘沉沦 提交于 2019-11-30 20:45:44
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.. 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 stderr or exit status because the commands run in a sub-shell, so you can only get stdout. The net-ssh-shell

Openshift and net-ssh incompatibility? (2.9.3-beta1 vs 2.9.2)

僤鯓⒐⒋嵵緔 提交于 2019-11-28 04:58:59
问题 by searching to access my Postgres DB on Openshift, i'm currently facing problem using net-ssh. At this step - note that the installed Ruby version is 2.2.0 and net-ssh is 2.9.3-beta1 To be able to access the DB from my local DB IDE, i need to execute: rhc port-forward myappname But the execution returns this error: Checking available ports ... Could not parse PKey: no start line As you can see in this post (an other ones e.g. this one), the fix is to back to a stable version of net-ssh. the

Net::SSH sudo command hangs after entering password

余生颓废 提交于 2019-11-27 05:49:06
问题 I've been trying to write a small library using Thor to help assist me in quick creating new projects and sites. I wrote this small method: def ssh(cmd) Net::SSH.start( server_ip, user, :port => port) do |session| session.exec cmd end end to just assist me in running quick commands on remote servers when needed. The problem is when I need to run a command under sudo on the remote end, the script just seems to hang on me. For example when executing this... ssh("sudo cp #{file_from_path} #{file