[ANN] Net::SSH 0.9.0

J

Jamis Buck

Net::SSH is a pure-Ruby implementation of an SSH2-compatible client.
It allows Ruby scripts to programmatically interact with remote
processes via SSH. It currently only supports version 2 of the SSH
protocol.

project page: http://rubyforge.org/projects/net-ssh
user manual: http://net-ssh.rubyforge.org
API docs: http://net-ssh.rubyforge.org/api

This release is (tentatively) the first in a series of beta releases
designed to get Net::SSH to 1.0 release status as soon as possible. It
includes the following feature additions and bug fixes:

* Added 'shell' and 'sync' services for interacting with users'
shells, including a demo script that uses these to implement a
simple SSH terminal client.

* The 'keyboard-interactive' authentication method is implemented
correctly now, which means users may receive a prompt to enter
a password if one is not given, and is required.

* The bug that caused the agent to always be used--even if it was
unavailable--has been fixed.

* The user manual now includes links to previous/next chapters, and
uses syntax highlighting for the code blocks. Various other style
tweaks in the manual.

* Window sizes and maximum packet sizes are now honored, which should
take care of various bugs and make Net::SSH play nicer with older
SSH servers.

* Non-blocking reads are now supported via the
Transport::Session#reader_ready? method. The
Connection::Driver#process method has been modified to make better
use of this.

* Moved to subversion, from CVS. Repository is now at
http://www.jamisbuck.org/svn/net-ssh

Please experiment with this release and report any bugs. Also, for
some reason the (now-ancient) 0.1.0 release of Net::SSH seems to be
a very popular gem download... if you are one of those that prefers
the 0.1.0 release to the current release, please drop me a line and
let me know why that is, so that I can make later release as
palatable. Thanks!
 
J

James Britt

Jamis said:
Net::SSH is a pure-Ruby implementation of an SSH2-compatible client.
It allows Ruby scripts to programmatically interact with remote
processes via SSH. It currently only supports version 2 of the SSH
protocol.


Hey, Jamis, get some sleep!

Syntax, Net::SHH ...

I expect a new Needle any minute now.


James
 
D

Dominik Werder

I get the following error when I start an example.
I installed net-ssh and needle with gems, I have ruby 1.8.2:


my$ ruby ssh-client.rb
.../lib/net/ssh/session.rb:17:in `require': No such file to load -- needle
(LoadError)
from ../lib/net/ssh/session.rb:17
from ../lib/net/ssh.rb:17:in `require'
from ../lib/net/ssh.rb:17
from ssh-client.rb:21:in `require'
from ssh-client.rb:21
 
J

Jamis Buck

I get the following error when I start an example.
I installed net-ssh and needle with gems, I have ruby 1.8.2:


my$ ruby ssh-client.rb
..../lib/net/ssh/session.rb:17:in `require': No such file to load -- needle
(LoadError)
from ../lib/net/ssh/session.rb:17
from ../lib/net/ssh.rb:17:in `require'
from ../lib/net/ssh.rb:17
from ssh-client.rb:21:in `require'
from ssh-client.rb:21

Can you try executing:

gem -v

and

echo $RUBYOPT

and

ruby -e 'require "needle"; p Needle::Registry'

It sounds like either needle didn't actually get installed (odd,
because net-ssh shouldn't install if the needle dependency isn't
satisfied), or you don't have the RUBYOPT environment variable set up
(should be at least "RUBYOPT=rubygems").

- Jamis
 
D

Dominik Werder

It sounds like either needle didn't actually get installed (odd,
because net-ssh shouldn't install if the needle dependency isn't
satisfied), or you don't have the RUBYOPT environment variable set up
(should be at least "RUBYOPT=rubygems").

You're right, $RUBYOPT was empty. Never heard about this variable..
Now it's working and I will explore a bit..

bye!
Dominik
 
J

Jamis Buck

Hello, I have a question and hope this is the correct area for it. If not
please feel free to direct me elsewhere.

Q:
I'm looking to implement an SSH based script/utility to connect to 8
different boxen, execute various commands and retrieve a file. The Perl
and Ant SSH implementation just don't seem to have what I need. I've
checked into this Ruby implementation and like it the best. I'm having a
problem tho, here's the code, based off Jamis' examples. Also the problem
seem to be when I call my method , @server isn't being recognized by my
Net:SSH call (getting socket error):

Code:

require 'net/ssh'


def do_sshget (sshserver)


@sshserver = sshserver

Net::SSH.start(
"@sshserver", 'user', 'passw',
^^^^^^^^^^^^

The problem is right there. Just use the sshserver variable directly,
like this:

Net::SSH.start( sshserver, 'user', 'passw',
:keys=>["C:\\SSH\\HostKeys"] )

Also, note that the backslashes are escpaed in the keys
string.

If you want to use string interpolation (where you specify an
expression inside the string and have it evaluated in the string), use
the "#{...}" syntax:

"#{@sshserver}"
# Copy the logs locally, can't find SCP in Ruby, shelling out to
Putty's pscp.exe
f=IO.popen("pscp -pw pass
user@"@sshserver":/home/user/log_archive/@sshserver.jar @sshserver.jar")
p f.readlines

Can you use SFTP? I'm "kind of" working on an SCP module for Ruby, but
it's hard going (the protocol is not documented at all, so I'm having
to extract it from the source code). In the meantime, there is
a pretty fully-functioning SFTP module for Ruby:

Net::SFTP.open( @sshserver, 'user', 'passw' ) do |sftp|
sftp.open_handle (
"/home/user/log_archive/#{@sshserver}.jar"
) do |handle|
log = sftp.read( handle )
p log
end
end

Hope that helps,

Jamis
 
J

Jamis Buck

And just
CODE:
def do_sshget (sshserver)



Net::SSH.start(sshserver, ...
...
end

The above _should_ work fine. The error you are getting seems to
indicate that the host name you are using is misformatted somehow, but
I'm definitely not familiar with networking issues on Windows. (Is
Daniel Berger around and watching this thread? If so, any thoughts?)
************************
I call with :
do_sshget("someserver123")
To no avail, same error
ERROR:
C:/ruby/lib/ruby/site_ruby/1.8/net/ssh/transport/session.rb:83:in
`initialize':
getaddrinfo: no address associated with hostname. (SocketError)
from
C:/ruby/lib/ruby/site_ruby/1.8/net/ssh/transport/session.rb:83:in `
open'

********************************
:( What the heck am I doing wrong?

I don't think SFTP is installed/active on these servers. Using pscp isn't
too much of a problem tho. I get the impression that scp is becoming
deprecated throughout most languages (at least Perl) but in the real world
its still on every box ;)

Yup, which is why I want to try and write this. Alas, as I mentioned,
it's a _real_ bear to implement. (Well, at least to understand. Once
understand it's actually pretty straightforward.)

- Jamis
 
J

Jamis Buck

You were right, not sure why but after a reboot I did the following. I
backed off to hard coding it in there. And it works, then added a method
call with hard coding and it worked. Then added method argument as posted
above ... and it worked!!

Not sure why it was failing earlier, could be windows.

First, thanks for writing this API!
Second, it works great!
Third, thanks for providing answers to my questions!

If I come across any SCP documentation, I'll post it here. I'd say I'd
help but I'm just learning Ruby myself (maybe in a year or two I'll catch
up!)

Good luck !

You're very welcome (on all three counts!). And welcome to Ruby! It's
a great a language, with one of the most incredible online communities
I've ever seen.

- Jamis
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

[ANN] Net::SSH 1.0.0 2
[ANN] Net::SSH 2.0.13 Released 0
[ANN] Net::SFTP 0.9.0 0
[ANN] Net::SSH 1.0.7 1
[ANN] Net::SSH 0.5.0 5
'net/ssh' error 3
[ANN] Net::SSH 0.1.0 2
[ANN] Net::SSH 0.6.0 11

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,059
Latest member
cryptoseoagencies

Latest Threads

Top