net-ssh

Using Ruby and net-ssh, how do I authenticate using the key_data parameter with Net::SSH.start?

二次信任 提交于 2019-12-18 13:27:59
问题 I've read the net-ssh documentation, and I am still perplexed. I can authenticate manually (using ssh -i ...), and also by placing the key in a file and using the :keys parameter. However, I dont want to use the :keys parameter, I want to use the :key_data parameter. Can anyone give a working example? For some reason, directly feeding a string into :key_data is not working, and it gives the error: "Neither PUB key nor PRIV key:: nested asn1 error". Of course I googled that, and it basically

How do I process a URL in ruby to extract the component parts (scheme, username, password, host, etc)?

淺唱寂寞╮ 提交于 2019-12-13 14:14:25
问题 I'm trying create a program using ruby (and Net::SSH) to connect to servers and perform some tasks. The details of the server are to be provided as something like: ssh://user:pass@host:port (for a host that does not yet have SSH keys) or user@host Net::SSH expects the following format: Net::SSH.start('host', 'user', :password => "password") Is there are gem/stdlib that can process the URL into this format? Or a simple regex that can match the different parts? Note: I'm aware of, and use,

How to read text from file into an array in ruby

99封情书 提交于 2019-12-11 16:56:14
问题 Is there a way to treat the HOST, USER, PASS varibales in the net - ssh gem as an array and have multiple values for them? I currently have an outside text file with the HOST, USER AND PASS values, but i need to pass these into the aforementioned variables within the net - ssh gem. Any help and edits to clarify the question are appreciated! :) 回答1: You should be able to do this using the splat operator. Have a read around on this, but Google quickly returns this intro. Using this, you can

Using ruby gem net-ssh to configure a Juniper router

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-11 06:27:45
问题 I'd like to be able to use the ruby net-ssh gem to make changes to a Juniper M10i router. However, after sending "configure", I am unable to send any configuration commands. For example, after logging in to the router via ssh, I'd like to issue the following three commands: configure show system exit Using the net-ssh library, i've tried the following without success: # net-ssh (2.3.0) require 'net/ssh' session = Net::SSH.start(host, user, :password => password) session.exec!('term length 0')

'no such file to load — net/ssh' from rails Controller on Ubuntu

笑着哭i 提交于 2019-12-11 04:23:49
问题 I have a very simple controller: require 'net/ssh' class MyController < ApplicationController def foo render :text => 'bar' end end But when I request http://server:3000/my/foo I get: MissingSourceFile in MyController#foo no such file to load -- net/ssh The gem is installed > gem list net-ssh *** LOCAL GEMS *** net-ssh (2.0.11) Also, I tried require 'net/ssh' in IRB, and it works. MyController works fine on Windows, but fail on Ubuntu. What can be wrong? 回答1: This may help: Rails Gem

Error “non-absolute home” via Net:SSH

浪尽此生 提交于 2019-12-08 17:07:33
问题 The code in question Net::SSH.start('server name', 'user') This returns "non-absolute home". The 'user' in fact does have a home directory. One suggested approach was to modify ~/.ssh/config with full paths to the IdentityFile. This did not solve the issue. The crazy part of this is that the code works fine if called through irb or console. The moment we try calling it from within a class method (with the same code) it returns the "non-absolute home" error. The 'user' can also ssh into the

Ruby net-ssh-multi: passing a password as a parameter at runtime

我怕爱的太早我们不能终老 提交于 2019-12-08 00:04:17
问题 I am trying to use net-ssh-multi to run a command on a group of servers. For this taks, ssh-key authentication is not an option; a password has to be passed to each server defined in the session.use lines. Here's the problem, 'net/ssh' can take a password parameter, but 'net/ssh/multi' cannot. What I would like to do is somehting like this: require 'net/ssh' require 'net/ssh/multi' #The necessary data is contained in a Ticket object my_ticket = Ticket.new Net::SSH::Multi.start (:password =>

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

坚强是说给别人听的谎言 提交于 2019-12-07 22:23:30
问题 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:

Ruby Net:SSH Control Master?

廉价感情. 提交于 2019-12-07 05:25:50
问题 I currently have a Ruby (Rails) application that needs to make a lot of short SSH connections. This works fine using the Ruby Net::SSH library, except that the app has to log in and negotiate keys every time I want to make a command, which is too slow. Is there a way to enable Control Master with Ruby Net::SSH? In testing on the command line, this makes logins (after the first one) very fast, since the connection is already open (keys are negotiated etc.). If there is no way to do this with

Cannot connect using keys with Ruby and net/ssh

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-06 20:50:26
问题 I'm having trouble connecting via ssh from ruby using the 'net-ssh' gem, getting Net::SSH::AuthenticationFailed. The code is below require 'net/ssh' keys = ["path_to_private_key"] Net::SSH.start('host', 'user',:keys => keys, :verbose => :debug) do |ssh| #ssh code end Using ssh directly from the command line works: ssh -i <path_to_private_key> user@host Do I have the the ssh API wrong? I have tried both 'user@host' and just 'user' as the username with the same result. Here is the debugging