views:

186

answers:

1

This is driving me crazy. I run into this every now and then on a new ubuntu/debian server. Basically I can't do a exec! through net-ssh. Note, that I can require 'net/ssh' perfectly fine.

sample code

require 'rubygems'
require 'net/ssh'

Net::SSH.start('my.random.box', 'myuser', :forward_agent => "true") do |ssh|

  #output = ssh.exec("hostname")
  #puts output 

  output = ssh.exec!("hostname")
  puts stdout
end

relevant system environment info

me@box:~$ gem list | grep net-ssh
net-ssh (2.0.11)
me@box:~$ which ruby
/usr/bin/ruby
me@box:~$ which gem
/usr/bin/gem


cyn0n@spicetrader:~$ gem environment
RubyGems Environment:
  - RUBYGEMS VERSION: 1.3.4
  - RUBY VERSION: 1.8.7 (2008-08-11 patchlevel 72) [i486-linux]
  - INSTALLATION DIRECTORY: /usr/lib/ruby/gems/1.8
  - RUBY EXECUTABLE: /usr/bin/ruby1.8
  - EXECUTABLE DIRECTORY: /usr/bin
  - RUBYGEMS PLATFORMS:
    - ruby
    - x86-linux
  - GEM PATHS:
     - /usr/lib/ruby/gems/1.8
     - /home/me/.gem/ruby/1.8
  - GEM CONFIGURATION:
     - :update_sources => true
     - :verbose => true
     - :benchmark => false
     - :backtrace => false
     - :bulk_threshold => 1000
     - :sources => ["http://gems.rubyforge.org/", "http://gems.github.com"]
  - REMOTE SOURCES:
     - http://gems.rubyforge.org/
     - http://gems.github.com
+1  A: 

A couple of things to try:

  1. Verify that the exec! method is in the source.
  2. Check both gem repositories to make sure there isn't an older net-ssh version in there. gem list has some oddities; it's more straightforward to just go into the directories and see what's there.
  3. require the current version in your script.

    require 'rubygems'

    gem 'net-ssh', '=2.0.11'

    require 'net-ssh'

Sarah Mei
thanks a lot Sarah!! the gem version helps out a lot!!! I still only found one net-ssh repo in /usr/lib/ruby/gems/1.8/gems.... although I did find a libnet-ssh-ruby1.8 which could be overriding the the net::ssh class
feydr