net-scp-1.1.1/ 0000755 0000041 0000041 00000000000 12164603536 013121 5 ustar www-data www-data net-scp-1.1.1/CHANGES.txt 0000644 0000041 0000041 00000001642 12164603536 014735 0 ustar www-data www-data
=== 1.1.1 / 13 May 2013
* Allow passing a shell to use when executing scp. [Arthur Schreiber]
=== 1.1.0 / 06 Feb 2013
* Added public cert. All gem releases are now signed. See INSTALL in readme.
=== 1.0.4 / 16 Sep 2010
* maintain filename sanitization compatibility with ruby 1.8.6 [Sung Pae, Tim Charper]
=== 1.0.3 / 17 Aug 2010
* replace :sanitize_file_name with a call to String#shellescape [Sung Pae]
* Added gemspec file and removed echoe dependency [Miron Cuperman, Delano Mandelbaum]
* Removed Hanna dependency in Rakefile [Delano Mandelbaum]
=== 1.0.2 / 4 Feb 2009
* Escape spaces in file names on remote server [Jamis Buck]
=== 1.0.1 / 29 May 2008
* Make sure downloads open the file in binary mode to appease Windows [Jamis Buck]
=== 1.0.0 / 1 May 2008
* Pass the channel object as the first argument to the progress callback [Jamis Buck]
=== 1.0 Preview Release 1 (0.99.0) / 22 Mar 2008
* Birthday!
net-scp-1.1.1/test/ 0000755 0000041 0000041 00000000000 12164603536 014100 5 ustar www-data www-data net-scp-1.1.1/test/test_download.rb 0000644 0000041 0000041 00000012644 12164603536 017302 0 ustar www-data www-data require 'common'
class TestDownload < Net::SCP::TestCase
def test_download_file_should_transfer_file
file = prepare_file("/path/to/local.txt", "a" * 1234)
expect_scp_session "-f /path/to/remote.txt" do |channel|
simple_download(channel)
end
assert_scripted { scp.download!("/path/to/remote.txt", "/path/to/local.txt") }
assert_equal "a" * 1234, file.io.string
end
def test_download_file_with_spaces_in_name_should_escape_remote_file_name
file = prepare_file("/path/to/local file.txt", "")
expect_scp_session "-f /path/to/remote\\ file.txt" do |channel|
channel.sends_ok
channel.gets_data "C0666 0 local file.txt\n"
channel.sends_ok
channel.gets_ok
channel.sends_ok
end
assert_scripted { scp.download!("/path/to/remote file.txt", "/path/to/local file.txt") }
end
def test_download_file_with_metacharacters_in_name_should_escape_remote_file_name
file = prepare_file("/path/to/local/#{awful_file_name}", "")
expect_scp_session "-f /path/to/remote/#{escaped_file_name}" do |channel|
channel.sends_ok
channel.gets_data "C0666 0 #{awful_file_name}\n"
channel.sends_ok
channel.gets_ok
channel.sends_ok
end
assert_scripted { scp.download!("/path/to/remote/#{awful_file_name}", "/path/to/local/#{awful_file_name}") }
end
def test_download_with_preserve_should_send_times
file = prepare_file("/path/to/local.txt", "a" * 1234, 0644, Time.at(1234567890, 123456), Time.at(12121212, 232323))
expect_scp_session "-f -p /path/to/remote.txt" do |channel|
channel.sends_ok
channel.gets_data "T1234567890 123456 12121212 232323\n"
simple_download(channel, 0644)
end
File.expects(:utime).with(Time.at(12121212, 232323), Time.at(1234567890, 123456), "/path/to/local.txt")
assert_scripted { scp.download!("/path/to/remote.txt", "/path/to/local.txt", :preserve => true) }
assert_equal "a" * 1234, file.io.string
end
def test_download_with_progress_callback_should_invoke_callback
prepare_file("/path/to/local.txt", "a" * 3000 + "b" * 3000 + "c" * 3000 + "d" * 3000)
expect_scp_session "-f /path/to/remote.txt" do |channel|
channel.sends_ok
channel.gets_data "C0666 12000 remote.txt\n"
channel.sends_ok
channel.gets_data "a" * 3000
channel.inject_remote_delay!
channel.gets_data "b" * 3000
channel.inject_remote_delay!
channel.gets_data "c" * 3000
channel.inject_remote_delay!
channel.gets_data "d" * 3000
channel.gets_ok
channel.sends_ok
end
calls = []
progress = Proc.new { |ch, *args| calls << args }
assert_scripted do
scp.download!("/path/to/remote.txt", "/path/to/local.txt", &progress)
end
assert_equal ["/path/to/local.txt", 0, 12000], calls.shift
assert_equal ["/path/to/local.txt", 3000, 12000], calls.shift
assert_equal ["/path/to/local.txt", 6000, 12000], calls.shift
assert_equal ["/path/to/local.txt", 9000, 12000], calls.shift
assert_equal ["/path/to/local.txt", 12000, 12000], calls.shift
assert calls.empty?
end
def test_download_io_with_recursive_should_raise_error
expect_scp_session "-f -r /path/to/remote.txt"
assert_raises(Net::SCP::Error) { scp.download!("/path/to/remote.txt", StringIO.new, :recursive => true) }
end
def test_download_io_with_preserve_should_ignore_preserve
expect_scp_session "-f -p /path/to/remote.txt" do |channel|
simple_download(channel)
end
io = StringIO.new
assert_scripted { scp.download!("/path/to/remote.txt", io, :preserve => true) }
assert_equal "a" * 1234, io.string
end
def test_download_io_should_transfer_data
expect_scp_session "-f /path/to/remote.txt" do |channel|
simple_download(channel)
end
io = StringIO.new
assert_scripted { scp.download!("/path/to/remote.txt", io) }
assert_equal "a" * 1234, io.string
end
def test_download_bang_without_target_should_return_string
expect_scp_session "-f /path/to/remote.txt" do |channel|
simple_download(channel)
end
assert_scripted do
assert_equal "a" * 1234, scp.download!("/path/to/remote.txt")
end
end
def test_download_directory_without_recursive_should_raise_error
expect_scp_session "-f /path/to/remote" do |channel|
channel.sends_ok
channel.gets_data "D0755 0 remote\n"
end
assert_raises(Net::SCP::Error) { scp.download!("/path/to/remote") }
end
def test_download_directory_should_create_directory_and_files_locally
file = nil
prepare_directory "/path/to/local" do |dir|
dir.directory "remote" do |dir2|
dir2.directory "sub" do |dir3|
file = dir3.file "remote.txt", ""
end
end
end
expect_scp_session "-f -r /path/to/remote" do |channel|
channel.sends_ok
channel.gets_data "D0755 0 remote\n"
channel.sends_ok
channel.gets_data "D0755 0 sub\n"
simple_download(channel)
channel.gets_data "E\n"
channel.sends_ok
channel.gets_data "E\n"
channel.sends_ok
end
scp.download!("/path/to/remote", "/path/to/local", :recursive => true, :ssh => { :verbose => :debug })
assert_equal "a" * 1234, file.io.string
end
private
def simple_download(channel, mode=0666)
channel.sends_ok
channel.gets_data "C%04o 1234 remote.txt\n" % mode
channel.sends_ok
channel.gets_data "a" * 1234
channel.gets_ok
channel.sends_ok
end
end
net-scp-1.1.1/test/common.rb 0000644 0000041 0000041 00000010764 12164603536 015725 0 ustar www-data www-data require 'test/unit'
require 'mocha/setup'
begin
gem 'net-ssh', ">= 2.0.0"
require 'net/ssh'
rescue LoadError
$LOAD_PATH.unshift "#{File.dirname(__FILE__)}/../../net-ssh/lib"
begin
require 'net/ssh'
require 'net/ssh/version'
raise LoadError, "wrong version" unless Net::SSH::Version::STRING >= '1.99.0'
rescue LoadError => e
abort "could not load net/ssh v2 (#{e.inspect})"
end
end
$LOAD_PATH.unshift "#{File.dirname(__FILE__)}/../lib"
require 'net/scp'
require 'net/ssh/test'
class Net::SSH::Test::Channel
def gets_ok
gets_data "\0"
end
def sends_ok
sends_data "\0"
end
end
class Net::SCP::TestCase < Test::Unit::TestCase
include Net::SSH::Test
def default_test
# do nothing, this is just a hacky-hack to work around Test::Unit's
# insistence that all TestCase subclasses have at least one test
# method defined.
end
protected
def prepare_file(path, contents="", mode=0666, mtime=Time.now, atime=Time.now)
entry = FileEntry.new(path, contents, mode, mtime, atime)
entry.stub!
entry
end
def prepare_directory(path, mode=0777, mtime=Time.now, atime=Time.now)
directory = DirectoryEntry.new(path, mode, mtime, atime)
yield directory if block_given?
directory.stub!
end
# The POSIX spec unfortunately allows all characters in file names except
# ASCII 0x00(NUL) and 0x2F(/)
#
# Ideally, we should be testing filenames with newlines, but Mocha doesn't
# like this at all, so we leave them out. However, the Shellwords module
# handles newlines just fine, so we can be reasonably confident that they
# will work in practice
def awful_file_name
(((0x00..0x7f).to_a - [0x00, 0x0a, 0x2f]).map { |n| n.chr }).join + '.txt'
end
def escaped_file_name
"\\\001\\\002\\\003\\\004\\\005\\\006\\\a\\\b\\\t\\\v\\\f\\\r\\\016\\\017\\\020\\\021\\\022\\\023\\\024\\\025\\\026\\\027\\\030\\\031\\\032\\\e\\\034\\\035\\\036\\\037\\ \\!\\\"\\#\\$\\%\\&\\'\\(\\)\\*\\+,-.0123456789:\\;\\<\\=\\>\\?@ABCDEFGHIJKLMNOPQRSTUVWXYZ\\[\\\\\\]\\^_\\`abcdefghijklmnopqrstuvwxyz\\{\\|\\}\\~\\\177.txt"
end
class FileEntry
attr_reader :path, :contents, :mode, :mtime, :atime, :io
def initialize(path, contents, mode=0666, mtime=Time.now, atime=Time.now)
@path, @contents, @mode = path, contents, mode
@mtime, @atime = mtime, atime
end
def name
@name ||= File.basename(path)
end
def stub!
stat = Mocha::Mock.new("file::stat")
stat.stubs(:size => contents.length, :mode => mode, :mtime => mtime, :atime => atime, :directory? => false)
File.stubs(:stat).with(path).returns(stat)
File.stubs(:directory?).with(path).returns(false)
File.stubs(:file?).with(path).returns(true)
File.stubs(:open).with(path, "rb").returns(StringIO.new(contents))
@io = StringIO.new
File.stubs(:new).with(path, "wb", mode).returns(io)
end
end
class DirectoryEntry
attr_reader :path, :mode, :mtime, :atime
attr_reader :entries
def initialize(path, mode=0777, mtime=Time.now, atime=Time.now)
@path, @mode = path, mode
@mtime, @atime = mtime, atime
@entries = []
end
def name
@name ||= File.basename(path)
end
def file(name, *args)
(entries << FileEntry.new(File.join(path, name), *args)).last
end
def directory(name, *args)
entry = DirectoryEntry.new(File.join(path, name), *args)
yield entry if block_given?
(entries << entry).last
end
def stub!
Dir.stubs(:mkdir).with { |*a| a.first == path }
stat = Mocha::Mock.new("file::stat")
stat.stubs(:size => 1024, :mode => mode, :mtime => mtime, :atime => atime, :directory? => true)
File.stubs(:stat).with(path).returns(stat)
File.stubs(:directory?).with(path).returns(true)
File.stubs(:file?).with(path).returns(false)
Dir.stubs(:entries).with(path).returns(%w(. ..) + entries.map { |e| e.name }.sort)
entries.each { |e| e.stub! }
end
end
def expect_scp_session(arguments)
story do |session|
channel = session.opens_channel
channel.sends_exec "scp #{arguments}"
yield channel if block_given?
channel.sends_eof
channel.gets_exit_status
channel.gets_eof
channel.gets_close
channel.sends_close
end
end
def scp(options={})
@scp ||= Net::SCP.new(connection(options))
end
end
net-scp-1.1.1/test/test_upload.rb 0000644 0000041 0000041 00000021333 12164603536 016752 0 ustar www-data www-data require 'common'
class TestUpload < Net::SCP::TestCase
def test_upload_file_should_transfer_file
prepare_file("/path/to/local.txt", "a" * 1234)
expect_scp_session "-t /path/to/remote.txt" do |channel|
channel.gets_ok
channel.sends_data "C0666 1234 local.txt\n"
channel.gets_ok
channel.sends_data "a" * 1234
channel.sends_ok
channel.gets_ok
end
assert_scripted { scp.upload!("/path/to/local.txt", "/path/to/remote.txt") }
end
def test_upload_file_with_spaces_in_name_should_escape_remote_file_name
prepare_file("/path/to/local file.txt", "")
expect_scp_session "-t /path/to/remote\\ file.txt" do |channel|
channel.gets_ok
channel.sends_data "C0666 0 local file.txt\n"
channel.gets_ok
channel.sends_ok
channel.gets_ok
end
assert_scripted { scp.upload!("/path/to/local file.txt", "/path/to/remote file.txt") }
end
def test_upload_file_with_metacharacters_in_name_should_escape_remote_file_name
prepare_file("/path/to/local/#{awful_file_name}", "")
expect_scp_session "-t /path/to/remote/#{escaped_file_name}" do |channel|
channel.gets_ok
channel.sends_data "C0666 0 #{awful_file_name}\n"
channel.gets_ok
channel.sends_ok
channel.gets_ok
end
assert_scripted { scp.upload!("/path/to/local/#{awful_file_name}", "/path/to/remote/#{awful_file_name}") }
end
def test_upload_file_with_preserve_should_send_times
prepare_file("/path/to/local.txt", "a" * 1234, 0666, Time.at(1234567890, 123456), Time.at(1234543210, 345678))
expect_scp_session "-t -p /path/to/remote.txt" do |channel|
channel.gets_ok
channel.sends_data "T1234567890 123456 1234543210 345678\n"
channel.gets_ok
channel.sends_data "C0666 1234 local.txt\n"
channel.gets_ok
channel.sends_data "a" * 1234
channel.sends_ok
channel.gets_ok
end
assert_scripted { scp.upload!("/path/to/local.txt", "/path/to/remote.txt", :preserve => true) }
end
def test_upload_file_with_progress_callback_should_invoke_callback
prepare_file("/path/to/local.txt", "a" * 3000 + "b" * 3000 + "c" * 3000 + "d" * 3000)
expect_scp_session "-t /path/to/remote.txt" do |channel|
channel.gets_ok
channel.sends_data "C0666 12000 local.txt\n"
channel.gets_ok
channel.sends_data "a" * 3000
channel.sends_data "b" * 3000
channel.sends_data "c" * 3000
channel.sends_data "d" * 3000
channel.sends_ok
channel.gets_ok
end
calls = []
progress = Proc.new do |ch, name, sent, total|
calls << [name, sent, total]
end
assert_scripted do
scp.upload!("/path/to/local.txt", "/path/to/remote.txt", :chunk_size => 3000, &progress)
end
assert_equal ["/path/to/local.txt", 0, 12000], calls.shift
assert_equal ["/path/to/local.txt", 3000, 12000], calls.shift
assert_equal ["/path/to/local.txt", 6000, 12000], calls.shift
assert_equal ["/path/to/local.txt", 9000, 12000], calls.shift
assert_equal ["/path/to/local.txt", 12000, 12000], calls.shift
assert calls.empty?
end
def test_upload_io_with_recursive_should_ignore_recursive
expect_scp_session "-t -r /path/to/remote.txt" do |channel|
channel.gets_ok
channel.sends_data "C0640 1234 remote.txt\n"
channel.gets_ok
channel.sends_data "a" * 1234
channel.sends_ok
channel.gets_ok
end
io = StringIO.new("a" * 1234)
assert_scripted { scp.upload!(io, "/path/to/remote.txt", :recursive => true) }
end
def test_upload_io_with_preserve_should_ignore_preserve
expect_scp_session "-t -p /path/to/remote.txt" do |channel|
channel.gets_ok
channel.sends_data "C0640 1234 remote.txt\n"
channel.gets_ok
channel.sends_data "a" * 1234
channel.sends_ok
channel.gets_ok
end
io = StringIO.new("a" * 1234)
assert_scripted { scp.upload!(io, "/path/to/remote.txt", :preserve => true) }
end
def test_upload_io_should_transfer_data
expect_scp_session "-t /path/to/remote.txt" do |channel|
channel.gets_ok
channel.sends_data "C0640 1234 remote.txt\n"
channel.gets_ok
channel.sends_data "a" * 1234
channel.sends_ok
channel.gets_ok
end
io = StringIO.new("a" * 1234)
assert_scripted { scp.upload!(io, "/path/to/remote.txt") }
end
def test_upload_io_with_mode_should_honor_mode_as_permissions
expect_scp_session "-t /path/to/remote.txt" do |channel|
channel.gets_ok
channel.sends_data "C0666 1234 remote.txt\n"
channel.gets_ok
channel.sends_data "a" * 1234
channel.sends_ok
channel.gets_ok
end
io = StringIO.new("a" * 1234)
assert_scripted { scp.upload!(io, "/path/to/remote.txt", :mode => 0666) }
end
def test_upload_directory_without_recursive_should_error
prepare_directory("/path/to/local")
expect_scp_session("-t /path/to/remote") do |channel|
channel.gets_ok
end
assert_raises(Net::SCP::Error) { scp.upload!("/path/to/local", "/path/to/remote") }
end
def test_upload_empty_directory_should_create_directory_and_finish
prepare_directory("/path/to/local")
expect_scp_session("-t -r /path/to/remote") do |channel|
channel.gets_ok
channel.sends_data "D0777 0 local\n"
channel.gets_ok
channel.sends_data "E\n"
channel.gets_ok
end
assert_scripted { scp.upload!("/path/to/local", "/path/to/remote", :recursive => true) }
end
def test_upload_directory_should_recursively_create_and_upload_items
prepare_directory("/path/to/local") do |d|
d.file "hello.txt", "hello world\n"
d.directory "others" do |d2|
d2.file "data.dat", "abcdefghijklmnopqrstuvwxyz"
end
d.file "zoo.doc", "going to the zoo\n"
end
expect_scp_session("-t -r /path/to/remote") do |channel|
channel.gets_ok
channel.sends_data "D0777 0 local\n"
channel.gets_ok
channel.sends_data "C0666 12 hello.txt\n"
channel.gets_ok
channel.sends_data "hello world\n"
channel.sends_ok
channel.gets_ok
channel.sends_data "D0777 0 others\n"
channel.gets_ok
channel.sends_data "C0666 26 data.dat\n"
channel.gets_ok
channel.sends_data "abcdefghijklmnopqrstuvwxyz"
channel.sends_ok
channel.gets_ok
channel.sends_data "E\n"
channel.gets_ok
channel.sends_data "C0666 17 zoo.doc\n"
channel.gets_ok
channel.sends_data "going to the zoo\n"
channel.sends_ok
channel.gets_ok
channel.sends_data "E\n"
channel.gets_ok
end
assert_scripted { scp.upload!("/path/to/local", "/path/to/remote", :recursive => true) }
end
def test_upload_directory_with_preserve_should_send_times_for_all_items
prepare_directory("/path/to/local", 0755, Time.at(17171717, 191919), Time.at(18181818, 101010)) do |d|
d.file "hello.txt", "hello world\n", 0640, Time.at(12345, 67890), Time.at(234567, 890)
d.directory "others", 0770, Time.at(112233, 4455), Time.at(22334455, 667788) do |d2|
d2.file "data.dat", "abcdefghijklmnopqrstuvwxyz", 0600, Time.at(13579135, 13131), Time.at(7654321, 654321)
end
d.file "zoo.doc", "going to the zoo\n", 0444, Time.at(12121212, 131313), Time.at(23232323, 242424)
end
expect_scp_session("-t -r -p /path/to/remote") do |channel|
channel.gets_ok
channel.sends_data "T17171717 191919 18181818 101010\n"
channel.gets_ok
channel.sends_data "D0755 0 local\n"
channel.gets_ok
channel.sends_data "T12345 67890 234567 890\n"
channel.gets_ok
channel.sends_data "C0640 12 hello.txt\n"
channel.gets_ok
channel.sends_data "hello world\n"
channel.sends_ok
channel.gets_ok
channel.sends_data "T112233 4455 22334455 667788\n"
channel.gets_ok
channel.sends_data "D0770 0 others\n"
channel.gets_ok
channel.sends_data "T13579135 13131 7654321 654321\n"
channel.gets_ok
channel.sends_data "C0600 26 data.dat\n"
channel.gets_ok
channel.sends_data "abcdefghijklmnopqrstuvwxyz"
channel.sends_ok
channel.gets_ok
channel.sends_data "E\n"
channel.gets_ok
channel.sends_data "T12121212 131313 23232323 242424\n"
channel.gets_ok
channel.sends_data "C0444 17 zoo.doc\n"
channel.gets_ok
channel.sends_data "going to the zoo\n"
channel.sends_ok
channel.gets_ok
channel.sends_data "E\n"
channel.gets_ok
end
assert_scripted { scp.upload!("/path/to/local", "/path/to/remote", :preserve => true, :recursive => true) }
end
def test_upload_should_not_block
prepare_file("/path/to/local.txt", "data")
story { |s| s.opens_channel(false) }
assert_scripted { scp.upload("/path/to/local.txt", "/path/to/remote.txt") }
end
end
net-scp-1.1.1/test/test_all.rb 0000644 0000041 0000041 00000000134 12164603536 016232 0 ustar www-data www-data Dir.chdir(File.dirname(__FILE__)) do
Dir['**/test_*.rb'].each { |file| require(file) }
end net-scp-1.1.1/test/test_scp.rb 0000644 0000041 0000041 00000003545 12164603536 016260 0 ustar www-data www-data require 'common'
class TestSCP < Net::SCP::TestCase
def test_start_without_block_should_return_scp_instance
ssh = stub('session', :logger => nil)
Net::SSH.expects(:start).
with("remote.host", "username", :password => "foo").
returns(ssh)
ssh.expects(:close).never
scp = Net::SCP.start("remote.host", "username", :password => "foo")
assert_instance_of Net::SCP, scp
assert_equal ssh, scp.session
end
def test_start_with_block_should_yield_scp_and_close_ssh_session
ssh = stub('session', :logger => nil)
Net::SSH.expects(:start).
with("remote.host", "username", :password => "foo").
returns(ssh)
ssh.expects(:loop)
ssh.expects(:close)
yielded = false
Net::SCP.start("remote.host", "username", :password => "foo") do |scp|
yielded = true
assert_instance_of Net::SCP, scp
assert_equal ssh, scp.session
end
assert yielded
end
def test_self_upload_should_instatiate_scp_and_invoke_synchronous_upload
scp = stub('scp')
scp.expects(:upload!).with("/path/to/local", "/path/to/remote", :recursive => true)
Net::SCP.expects(:start).
with("remote.host", "username", :password => "foo").
yields(scp)
Net::SCP.upload!("remote.host", "username", "/path/to/local", "/path/to/remote",
:ssh => { :password => "foo" }, :recursive => true)
end
def test_self_download_should_instatiate_scp_and_invoke_synchronous_download
scp = stub('scp')
scp.expects(:download!).with("/path/to/remote", "/path/to/local", :recursive => true).returns(:result)
Net::SCP.expects(:start).
with("remote.host", "username", :password => "foo").
yields(scp)
result = Net::SCP.download!("remote.host", "username", "/path/to/remote", "/path/to/local",
:ssh => { :password => "foo" }, :recursive => true)
assert_equal :result, result
end
end
net-scp-1.1.1/README.rdoc 0000644 0000041 0000041 00000007754 12164603536 014744 0 ustar www-data www-data = Net::SCP
* Docs: http://net-ssh.github.com/net-scp
* Issues: https://github.com/net-ssh/net-scp/issues
* Codes: https://github.com/net-ssh/net-scp
* Email: net-ssh@solutious.com
As of v1.0.5, all gem releases are signed. See INSTALL.
== DESCRIPTION:
Net::SCP is a pure-Ruby implementation of the SCP protocol. This operates over SSH (and requires the Net::SSH library), and allows files and directory trees to copied to and from a remote server.
== FEATURES/PROBLEMS:
* Transfer files or entire directory trees to or from a remote host via SCP
* Can preserve file attributes across transfers
* Can download files in-memory, or direct-to-disk
* Support for SCP URI's, and OpenURI
== SYNOPSIS:
In a nutshell:
require 'net/scp'
# upload a file to a remote server
Net::SCP.upload!("remote.host.com", "username",
"/local/path", "/remote/path",
:password => "password")
# download a file from a remote server
Net::SCP.download!("remote.host.com", "username",
"/remote/path", "/local/path",
:password => password)
# download a file to an in-memory buffer
data = Net::SCP::download!("remote.host.com", "username", "/remote/path")
# use a persistent connection to transfer files
Net::SCP.start("remote.host.com", "username", :password => "password") do |scp|
# upload a file to a remote server
scp.upload! "/local/path", "/remote/path"
# upload from an in-memory buffer
scp.upload! StringIO.new("some data to upload"), "/remote/path"
# run multiple downloads in parallel
d1 = scp.download("/remote/path", "/local/path")
d2 = scp.download("/remote/path2", "/local/path2")
[d1, d2].each { |d| d.wait }
end
# You can also use open-uri to grab data via scp:
require 'uri/open-scp'
data = open("scp://user@host/path/to/file.txt").read
For more information, see Net::SCP.
== REQUIREMENTS:
* Net::SSH 2
If you wish to run the tests, you'll also need:
* Echoe (for Rakefile use)
* Mocha (for tests)
== INSTALL:
* gem install net-scp (might need sudo privileges)
However, in order to be sure the code you're installing hasn't been tampered with, it's recommended that you verify the signiture[http://docs.rubygems.org/read/chapter/21]. To do this, you need to add my public key as a trusted certificate (you only need to do this once):
# Add the public key as a trusted certificate
# (You only need to do this once)
$ curl -O https://raw.github.com/net-ssh/net-ssh/master/gem-public_cert.pem
$ gem cert --add gem-public_cert.pem
Then, when install the gem, do so with high security:
$ gem install net-scp -P HighSecurity
If you don't add the public key, you'll see an error like "Couldn't verify data signature". If you're still having trouble let me know and I'll give you a hand.
Or, you can do it the hard way (without Rubygems):
* tar xzf net-scp-*.tgz
* cd net-scp-*
* ruby setup.rb config
* ruby setup.rb install (might need sudo privileges)
== LICENSE:
(The MIT License)
Copyright (c) 2008 Jamis Buck
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
'Software'), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
net-scp-1.1.1/Rakefile 0000644 0000041 0000041 00000003050 12164603536 014564 0 ustar www-data www-data require "rubygems"
require "rake"
require "rake/clean"
require "rdoc/task"
task :default => ["build"]
CLEAN.include [ 'pkg', 'rdoc' ]
name = "net-scp"
$:.unshift File.join(File.dirname(__FILE__), 'lib')
require "net/scp/version"
version = Net::SCP::Version::STRING.dup
begin
require "jeweler"
Jeweler::Tasks.new do |s|
s.version = version
s.name = name
s.rubyforge_project = s.name
s.summary = "A pure Ruby implementation of the SCP client protocol"
s.description = s.summary
s.email = "net-ssh@solutious.com"
s.homepage = "https://github.com/net-ssh/net-scp"
s.authors = ["Jamis Buck", "Delano Mandelbaum"]
s.add_dependency 'net-ssh', ">=2.6.5"
s.add_development_dependency 'test-unit'
s.add_development_dependency 'mocha'
s.license = "MIT"
s.signing_key = File.join('/mnt/gem/', 'gem-private_key.pem')
s.cert_chain = ['gem-public_cert.pem']
end
Jeweler::GemcutterTasks.new
rescue LoadError
puts "Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler"
end
require 'rake/testtask'
Rake::TestTask.new do |t|
t.libs = ["lib", "test"]
end
extra_files = %w[LICENSE.txt THANKS.txt CHANGES.txt ]
RDoc::Task.new do |rdoc|
rdoc.rdoc_dir = "rdoc"
rdoc.title = "#{name} #{version}"
rdoc.generator = 'hanna' # gem install hanna-nouveau
rdoc.main = 'README.rdoc'
rdoc.rdoc_files.include("README*")
rdoc.rdoc_files.include("bin/*.rb")
rdoc.rdoc_files.include("lib/**/*.rb")
extra_files.each { |file|
rdoc.rdoc_files.include(file) if File.exists?(file)
}
end
net-scp-1.1.1/net-scp.gemspec 0000644 0000041 0000041 00000003765 12164603536 016052 0 ustar www-data www-data # Generated by jeweler
# DO NOT EDIT THIS FILE DIRECTLY
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
# -*- encoding: utf-8 -*-
Gem::Specification.new do |s|
s.name = "net-scp"
s.version = "1.1.1"
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
s.authors = ["Jamis Buck", "Delano Mandelbaum"]
s.cert_chain = ["gem-public_cert.pem"]
s.date = "2013-05-13"
s.description = "A pure Ruby implementation of the SCP client protocol"
s.email = "net-ssh@solutious.com"
s.extra_rdoc_files = [
"LICENSE.txt",
"README.rdoc"
]
s.files = [
"CHANGES.txt",
"LICENSE.txt",
"Manifest",
"README.rdoc",
"Rakefile",
"gem-public_cert.pem",
"lib/net/scp.rb",
"lib/net/scp/download.rb",
"lib/net/scp/errors.rb",
"lib/net/scp/upload.rb",
"lib/net/scp/version.rb",
"lib/uri/open-scp.rb",
"lib/uri/scp.rb",
"net-scp.gemspec",
"setup.rb",
"test/common.rb",
"test/test_all.rb",
"test/test_download.rb",
"test/test_scp.rb",
"test/test_upload.rb"
]
s.homepage = "https://github.com/net-ssh/net-scp"
s.licenses = ["MIT"]
s.require_paths = ["lib"]
s.rubyforge_project = "net-scp"
s.rubygems_version = "1.8.25"
s.signing_key = "/mnt/gem/gem-private_key.pem"
s.summary = "A pure Ruby implementation of the SCP client protocol"
if s.respond_to? :specification_version then
s.specification_version = 3
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
s.add_runtime_dependency(%q, [">= 2.6.5"])
s.add_development_dependency(%q, [">= 0"])
s.add_development_dependency(%q, [">= 0"])
else
s.add_dependency(%q, [">= 2.6.5"])
s.add_dependency(%q, [">= 0"])
s.add_dependency(%q, [">= 0"])
end
else
s.add_dependency(%q, [">= 2.6.5"])
s.add_dependency(%q, [">= 0"])
s.add_dependency(%q, [">= 0"])
end
end
net-scp-1.1.1/LICENSE.txt 0000644 0000041 0000041 00000002045 12164603536 014745 0 ustar www-data www-data Copyright © 2008 Jamis Buck
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the ‘Software’), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED ‘AS IS’, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
net-scp-1.1.1/gem-public_cert.pem 0000644 0000041 0000041 00000002230 12164603536 016662 0 ustar www-data www-data -----BEGIN CERTIFICATE-----
MIIDNjCCAh6gAwIBAgIBADANBgkqhkiG9w0BAQUFADBBMQ8wDQYDVQQDDAZkZWxh
bm8xGTAXBgoJkiaJk/IsZAEZFglzb2x1dGlvdXMxEzARBgoJkiaJk/IsZAEZFgNj
b20wHhcNMTMwMjA2MTE1NzQ1WhcNMTQwMjA2MTE1NzQ1WjBBMQ8wDQYDVQQDDAZk
ZWxhbm8xGTAXBgoJkiaJk/IsZAEZFglzb2x1dGlvdXMxEzARBgoJkiaJk/IsZAEZ
FgNjb20wggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDg1hMtl0XsMuUK
AKTgYWv3gjj7vuEsE2EjT+vyBg8/LpqVVwZziiaebJT9IZiQ+sCFqbiakj0b53pI
hg1yOaBEmH6/W0L7rwzqaRV9sW1eJs9JxFYQCnd67zUnzj8nnRlOjG+hhIG+Vsij
npsGbt28pefuNZJjO5q2clAlfSniIIHfIsU7/StEYu6FUGOjnwryZ0r5yJlr9RrE
Gs+q0DW8QnZ9UpAfuDFQZuIqeKQFFLE7nMmCGaA+0BN1nLl3fVHNbLHq7Avk8+Z+
ZuuvkdscbHlO/l+3xCNQ5nUnHwq0ADAbMLOlmiYYzqXoWLjmeI6me/clktJCfN2R
oZG3UQvvAgMBAAGjOTA3MAkGA1UdEwQCMAAwHQYDVR0OBBYEFMSJOEtHzE4l0azv
M0JK0kKNToK1MAsGA1UdDwQEAwIEsDANBgkqhkiG9w0BAQUFAAOCAQEAtOdE73qx
OH2ydi9oT2hS5f9G0y1Z70Tlwh+VGExyfxzVE9XwC+iPpJxNraiHYgF/9/oky7ZZ
R9q0/tJneuhAenZdiQkX7oi4O3v9wRS6YHoWBxMPFKVRLNTzvVJsbmfpCAlp5/5g
ps4wQFy5mibElGVlOobf/ghqZ25HS9J6kd0/C/ry0AUtTogsL7TxGwT4kbCx63ub
3vywEEhsJUzfd97GCABmtQfRTldX/j7F1z/5wd8p+hfdox1iibds9ZtfaZA3KzKn
kchWN9B6zg9r1XMQ8BM2Jz0XoPanPe354+lWwjpkRKbFow/ZbQHcCLCq24+N6b6g
dgKfNDzwiDpqCA==
-----END CERTIFICATE-----
net-scp-1.1.1/Manifest 0000644 0000041 0000041 00000000436 12164603536 014615 0 ustar www-data www-data CHANGELOG.rdoc
lib/net/scp/download.rb
lib/net/scp/errors.rb
lib/net/scp/upload.rb
lib/net/scp/version.rb
lib/net/scp.rb
lib/uri/open-scp.rb
lib/uri/scp.rb
Rakefile
README.rdoc
setup.rb
test/common.rb
test/test_all.rb
test/test_download.rb
test/test_scp.rb
test/test_upload.rb
Manifest
net-scp-1.1.1/metadata.yml 0000644 0000041 0000041 00000010254 12164603536 015426 0 ustar www-data www-data --- !ruby/object:Gem::Specification
name: net-scp
version: !ruby/object:Gem::Version
version: 1.1.1
prerelease:
platform: ruby
authors:
- Jamis Buck
- Delano Mandelbaum
autorequire:
bindir: bin
cert_chain:
- !binary |-
LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSUROakNDQWg2Z0F3SUJB
Z0lCQURBTkJna3Foa2lHOXcwQkFRVUZBREJCTVE4d0RRWURWUVFEREFaa1pX
eGgKYm04eEdUQVhCZ29Ka2lhSmsvSXNaQUVaRmdsemIyeDFkR2x2ZFhNeEV6
QVJCZ29Ka2lhSmsvSXNaQUVaRmdOagpiMjB3SGhjTk1UTXdNakEyTVRFMU56
UTFXaGNOTVRRd01qQTJNVEUxTnpRMVdqQkJNUTh3RFFZRFZRUUREQVprClpX
eGhibTh4R1RBWEJnb0praWFKay9Jc1pBRVpGZ2x6YjJ4MWRHbHZkWE14RXpB
UkJnb0praWFKay9Jc1pBRVoKRmdOamIyMHdnZ0VpTUEwR0NTcUdTSWIzRFFF
QkFRVUFBNElCRHdBd2dnRUtBb0lCQVFEZzFoTXRsMFhzTXVVSwpBS1RnWVd2
M2dqajd2dUVzRTJFalQrdnlCZzgvTHBxVlZ3WnppaWFlYkpUOUlaaVErc0NG
cWJpYWtqMGI1M3BJCmhnMXlPYUJFbUg2L1cwTDdyd3pxYVJWOXNXMWVKczlK
eEZZUUNuZDY3elVuemo4bm5SbE9qRytoaElHK1ZzaWoKbnBzR2J0MjhwZWZ1
TlpKak81cTJjbEFsZlNuaUlJSGZJc1U3L1N0RVl1NkZVR09qbndyeVowcjV5
SmxyOVJyRQpHcytxMERXOFFuWjlVcEFmdURGUVp1SXFlS1FGRkxFN25NbUNH
YUErMEJOMW5MbDNmVkhOYkxIcTdBdms4K1orClp1dXZrZHNjYkhsTy9sKzN4
Q05RNW5Vbkh3cTBBREFiTUxPbG1pWVl6cVhvV0xqbWVJNm1lL2Nsa3RKQ2ZO
MlIKb1pHM1VRdnZBZ01CQUFHak9UQTNNQWtHQTFVZEV3UUNNQUF3SFFZRFZS
ME9CQllFRk1TSk9FdEh6RTRsMGF6dgpNMEpLMGtLTlRvSzFNQXNHQTFVZER3
UUVBd0lFc0RBTkJna3Foa2lHOXcwQkFRVUZBQU9DQVFFQXRPZEU3M3F4Ck9I
MnlkaTlvVDJoUzVmOUcweTFaNzBUbHdoK1ZHRXh5Znh6VkU5WHdDK2lQcEp4
TnJhaUhZZ0YvOS9va3k3WloKUjlxMC90Sm5ldWhBZW5aZGlRa1g3b2k0TzN2
OXdSUzZZSG9XQnhNUEZLVlJMTlR6dlZKc2JtZnBDQWxwNS81ZwpwczR3UUZ5
NW1pYkVsR1ZsT29iZi9naHFaMjVIUzlKNmtkMC9DL3J5MEFVdFRvZ3NMN1R4
R3dUNGtiQ3g2M3ViCjN2eXdFRWhzSlV6ZmQ5N0dDQUJtdFFmUlRsZFgvajdG
MXovNXdkOHAraGZkb3gxaWliZHM5WnRmYVpBM0t6S24Ka2NoV045QjZ6Zzly
MVhNUThCTTJKejBYb1BhblBlMzU0K2xXd2pwa1JLYkZvdy9aYlFIY0NMQ3Ey
NCtONmI2ZwpkZ0tmTkR6d2lEcHFDQT09Ci0tLS0tRU5EIENFUlRJRklDQVRF
LS0tLS0K
date: 2013-05-13 00:00:00.000000000 Z
dependencies:
- !ruby/object:Gem::Dependency
name: net-ssh
requirement: !ruby/object:Gem::Requirement
none: false
requirements:
- - ! '>='
- !ruby/object:Gem::Version
version: 2.6.5
type: :runtime
prerelease: false
version_requirements: !ruby/object:Gem::Requirement
none: false
requirements:
- - ! '>='
- !ruby/object:Gem::Version
version: 2.6.5
- !ruby/object:Gem::Dependency
name: test-unit
requirement: !ruby/object:Gem::Requirement
none: false
requirements:
- - ! '>='
- !ruby/object:Gem::Version
version: '0'
type: :development
prerelease: false
version_requirements: !ruby/object:Gem::Requirement
none: false
requirements:
- - ! '>='
- !ruby/object:Gem::Version
version: '0'
- !ruby/object:Gem::Dependency
name: mocha
requirement: !ruby/object:Gem::Requirement
none: false
requirements:
- - ! '>='
- !ruby/object:Gem::Version
version: '0'
type: :development
prerelease: false
version_requirements: !ruby/object:Gem::Requirement
none: false
requirements:
- - ! '>='
- !ruby/object:Gem::Version
version: '0'
description: A pure Ruby implementation of the SCP client protocol
email: net-ssh@solutious.com
executables: []
extensions: []
extra_rdoc_files:
- LICENSE.txt
- README.rdoc
files:
- CHANGES.txt
- LICENSE.txt
- Manifest
- README.rdoc
- Rakefile
- gem-public_cert.pem
- lib/net/scp.rb
- lib/net/scp/download.rb
- lib/net/scp/errors.rb
- lib/net/scp/upload.rb
- lib/net/scp/version.rb
- lib/uri/open-scp.rb
- lib/uri/scp.rb
- net-scp.gemspec
- setup.rb
- test/common.rb
- test/test_all.rb
- test/test_download.rb
- test/test_scp.rb
- test/test_upload.rb
homepage: https://github.com/net-ssh/net-scp
licenses:
- MIT
post_install_message:
rdoc_options: []
require_paths:
- lib
required_ruby_version: !ruby/object:Gem::Requirement
none: false
requirements:
- - ! '>='
- !ruby/object:Gem::Version
version: '0'
required_rubygems_version: !ruby/object:Gem::Requirement
none: false
requirements:
- - ! '>='
- !ruby/object:Gem::Version
version: '0'
requirements: []
rubyforge_project: net-scp
rubygems_version: 1.8.25
signing_key:
specification_version: 3
summary: A pure Ruby implementation of the SCP client protocol
test_files: []
net-scp-1.1.1/metadata.gz.sig 0000644 0000041 0000041 00000000400 12164603536 016016 0 ustar www-data www-data >W^ˑoF)㴀V݃]hrFJo'ih .t:%ʗv0;N)N\^՞ƮYݚb$,tQ\#HGSM hHr m1=|毶s8kmZȰW~kE$2bhL%+b$c`p sP|o[PBT#a( OPpX5͛p.l
h7{