Class: SSHKit::Backend::Libssh
- Inherits:
-
Abstract
- Object
- Abstract
- SSHKit::Backend::Libssh
- Defined in:
- lib/sshkit/backends/libssh.rb
Overview
SSHKit backend class for libssh.
Defined Under Namespace
Classes: Configuration
Class Attribute Summary collapse
-
.pool ⇒ SSHKit::Backend::ConnectionPool
Connection pool for libssh.
Class Method Summary collapse
-
.config ⇒ Configuration
Global configuration for Netssh.
Instance Method Summary collapse
-
#download!(remote, local, _options = {}) ⇒ Object
Download a remote file to local.
-
#upload!(local, remote, _options = {}) ⇒ Object
Upload a local file to the remote party.
Class Attribute Details
.pool ⇒ SSHKit::Backend::ConnectionPool
Connection pool for libssh.
99 100 101 |
# File 'lib/sshkit/backends/libssh.rb', line 99 def pool @pool end |
Class Method Details
.config ⇒ Configuration
Global configuration for Netssh.
103 104 105 |
# File 'lib/sshkit/backends/libssh.rb', line 103 def config @config ||= Configuration.new end |
Instance Method Details
#download!(remote, local, _options = {}) ⇒ Object
TODO:
Make options
compatible with Netssh#download!.
Download a remote file to local.
74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 |
# File 'lib/sshkit/backends/libssh.rb', line 74 def download!(remote, local, = {}) with_session do |session| scp = LibSSH::Scp.new(session, :read, remote) scp.init do loop do case scp.pull_request when LibSSH::Scp::REQUEST_NEWFILE info "Downloading #{remote}" download_file(scp, local) when LibSSH::Scp::REQUEST_NEWDIR scp.deny_request('Only NEWFILE is acceptable') when LibSSH::Scp::REQUEST_EOF break end end end end end |
#upload!(local, remote, _options = {}) ⇒ Object
TODO:
Make options
compatible with Netssh#upload!.
Upload a local file to the remote party.
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/sshkit/backends/libssh.rb', line 48 def upload!(local, remote, = {}) with_session do |session| scp = LibSSH::Scp.new(session, :write, File.dirname(remote)) wrap_local_reader(local) do |io, mode| scp.init do scp.push_file(File.basename(remote), io.size, mode) info "Uploading #{remote}" begin loop do scp.write(io.readpartial(BUFSIZ)) end # rubocop:disable Lint/HandleExceptions rescue EOFError end end end end end |