Module Net::SFTP
In: lib/net/sftp/constants.rb
lib/net/sftp/errors.rb
lib/net/sftp/operations/dir.rb
lib/net/sftp/operations/download.rb
lib/net/sftp/operations/file.rb
lib/net/sftp/operations/file_factory.rb
lib/net/sftp/operations/upload.rb
lib/net/sftp/packet.rb
lib/net/sftp/protocol/01/attributes.rb
lib/net/sftp/protocol/01/base.rb
lib/net/sftp/protocol/01/name.rb
lib/net/sftp/protocol/02/base.rb
lib/net/sftp/protocol/03/base.rb
lib/net/sftp/protocol/04/attributes.rb
lib/net/sftp/protocol/04/base.rb
lib/net/sftp/protocol/04/name.rb
lib/net/sftp/protocol/05/base.rb
lib/net/sftp/protocol/06/attributes.rb
lib/net/sftp/protocol/06/base.rb
lib/net/sftp/protocol/base.rb
lib/net/sftp/protocol.rb
lib/net/sftp/request.rb
lib/net/sftp/response.rb
lib/net/sftp/session.rb
lib/net/sftp/version.rb
lib/net/sftp.rb

Net::SFTP is a pure-Ruby module for programmatically interacting with a remote host via the SFTP protocol (that‘s SFTP as in "Secure File Transfer Protocol" produced by the Secure Shell Working Group, not "Secure FTP" and certainly not "Simple FTP").

See Net::SFTP#start for an introduction to the library. Also, see Net::SFTP::Session for further documentation.

Methods

start  

Classes and Modules

Module Net::SFTP::Constants
Module Net::SFTP::Operations
Module Net::SFTP::Protocol
Class Net::SFTP::Exception
Class Net::SFTP::Packet
Class Net::SFTP::Request
Class Net::SFTP::Response
Class Net::SFTP::Session
Class Net::SFTP::StatusException
Class Net::SFTP::Version

Public Class methods

A convenience method for starting a standalone SFTP session. It will start up an SSH session using the given arguments (see the documentation for Net::SSH::Session for details), and will then start a new SFTP session with the SSH session. This will block until the new SFTP is fully open and initialized before returning it.

  sftp = Net::SFTP.start("localhost", "user")
  sftp.upload! "/local/file.tgz", "/remote/file.tgz"

If a block is given, it will be passed to the SFTP session and will be called once the SFTP session is fully open and initialized. When the block terminates, the new SSH session will automatically be closed.

  Net::SFTP.start("localhost", "user") do |sftp|
    sftp.upload! "/local/file.tgz", "/remote/file.tgz"
  end

[Source]

    # File lib/net/sftp.rb, line 30
30:     def self.start(host, user, options={}, &block)
31:       session = Net::SSH.start(host, user, options)
32:       sftp = Net::SFTP::Session.new(session, &block).connect!
33: 
34:       sftp.loop if block_given?
35: 
36:       sftp
37:     ensure
38:       session.close if session && block_given?
39:     end

[Validate]