这真让我抓狂。我时不时地在一个新的 ubuntu/debian 服务器上遇到这个问题。基本上我不能做一个执行!通过 net-ssh。请注意,我可以要求 'net/ssh' 非常好。
示例代码
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
相关系统环境信息
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