net-ssh help

  • Thread starter Carl Youngblood
  • Start date
C

Carl Youngblood

Hello,
I'm trying to use net-ssh for the first time and having some trouble.
Any help would be greatly appreciated.

In a simple script I'm running with the first few lines like so:

Net::SSH.start('myhost, 'user', 'pass') do |session|
Net::SSH::SFTP.session(session) do |sftp|
if not sftp.put_file(domainfile, "blocks/#{domainfile}")
raise "Couldn't upload domain file"
end
if not sftp.put_file(actionfile, "blocks/#{actionfile}")
raise "Couldn't upload action file"
end
end
end

I get the following error:

could not load public key file '/Users/carl/.ssh/id_rsa.pub'
(uninitialized constant OpenSSL::pKey::pKey::Base64 [NameError])

I'm wondering why it fails trying to load the public key file when A)
it's there and it's readable by the current user, and B) I've already
specified the username and password explicitly, so it doesn't matter
if it succeeds in reading the public key file.

I figured maybe there was something special in rb-keygen beyond what
was in ssh-keygen, so I ran it, but I got the following error when I
did that:

/usr/local/bin/rb-keygen:25:in `require': No such file to load --
net/ssh/transport/buffer (LoadError)
from /usr/local/bin/rb-keygen:25

I installed net-ssh using the setup.rb method, in case it helps. And
I'm using OS X.

Thanks,
Carl
 
J

Jamis Buck

Carl said:
Hello,
I'm trying to use net-ssh for the first time and having some trouble.
Any help would be greatly appreciated.

In a simple script I'm running with the first few lines like so:

Net::SSH.start('myhost, 'user', 'pass') do |session|
Net::SSH::SFTP.session(session) do |sftp|
if not sftp.put_file(domainfile, "blocks/#{domainfile}")
raise "Couldn't upload domain file"
end
if not sftp.put_file(actionfile, "blocks/#{actionfile}")
raise "Couldn't upload action file"
end
end
end

I get the following error:

could not load public key file '/Users/carl/.ssh/id_rsa.pub'
(uninitialized constant OpenSSL::pKey::pKey::Base64 [NameError])

Carl,

A few questions: what version of Ruby are you using? Do you get a
backtrace with the error? If so, could you post it?

The problem, it looks like, is that the Base64 library cannot be found,
which is worrisome, since it's part of the standard library. If that
can't be found, then either (a) you're using a pre-1.8 version of Ruby,
or (b) you're Ruby installation is incorrect or incomplete.
I'm wondering why it fails trying to load the public key file when A)
it's there and it's readable by the current user, and B) I've already
specified the username and password explicitly, so it doesn't matter
if it succeeds in reading the public key file.

The failure isn't because the file couldn't be opened, its because the
Base64 module couldn't be found while the key was being processed.
I figured maybe there was something special in rb-keygen beyond what
was in ssh-keygen, so I ran it, but I got the following error when I
did that:

/usr/local/bin/rb-keygen:25:in `require': No such file to load --
net/ssh/transport/buffer (LoadError)
from /usr/local/bin/rb-keygen:25

This seems to indicate a borked installation as well... perhaps your
Ruby load paths are wrong? Try this:

ruby -e 'p $:'

Could you send me the paths that it emits? Also:

ruby -rnet/ssh -e 'p $"'

Could you send me that output of that command?

- Jamis
 
B

Brian Candler

I get the following error:

could not load public key file '/Users/carl/.ssh/id_rsa.pub'
(uninitialized constant OpenSSL::pKey::pKey::Base64 [NameError])

what happens if you do in irb:

require 'base64'
Base64.decode64("aGVsbG8h\n")
 
C

Carl Youngblood

Thanks for the tips. I'm not in front of my mac now, but my ruby
setup was installed from CVS about 6 months ago and has accumulated a
lot of cruft over time. I've been wanting to clean things up for a
while now, so I think maybe I'll kill it and start from scratch again,
this time with a stable release.

Carl said:
Hello,
I'm trying to use net-ssh for the first time and having some trouble.
Any help would be greatly appreciated.

In a simple script I'm running with the first few lines like so:

Net::SSH.start('myhost, 'user', 'pass') do |session|
Net::SSH::SFTP.session(session) do |sftp|
if not sftp.put_file(domainfile, "blocks/#{domainfile}")
raise "Couldn't upload domain file"
end
if not sftp.put_file(actionfile, "blocks/#{actionfile}")
raise "Couldn't upload action file"
end
end
end

I get the following error:

could not load public key file '/Users/carl/.ssh/id_rsa.pub'
(uninitialized constant OpenSSL::pKey::pKey::Base64 [NameError])

Carl,

A few questions: what version of Ruby are you using? Do you get a
backtrace with the error? If so, could you post it?

The problem, it looks like, is that the Base64 library cannot be found,
which is worrisome, since it's part of the standard library. If that
can't be found, then either (a) you're using a pre-1.8 version of Ruby,
or (b) you're Ruby installation is incorrect or incomplete.
I'm wondering why it fails trying to load the public key file when A)
it's there and it's readable by the current user, and B) I've already
specified the username and password explicitly, so it doesn't matter
if it succeeds in reading the public key file.

The failure isn't because the file couldn't be opened, its because the
Base64 module couldn't be found while the key was being processed.
I figured maybe there was something special in rb-keygen beyond what
was in ssh-keygen, so I ran it, but I got the following error when I
did that:

/usr/local/bin/rb-keygen:25:in `require': No such file to load --
net/ssh/transport/buffer (LoadError)
from /usr/local/bin/rb-keygen:25

This seems to indicate a borked installation as well... perhaps your
Ruby load paths are wrong? Try this:

ruby -e 'p $:'

Could you send me the paths that it emits? Also:

ruby -rnet/ssh -e 'p $"'

Could you send me that output of that command?

- 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

Members online

No members online now.

Forum statistics

Threads
473,794
Messages
2,569,641
Members
45,354
Latest member
OrenKrause

Latest Threads

Top