Class: SSHKit::EC2InstanceConnect::Backend
- Inherits:
-
Backend::Abstract
- Object
- Backend::Abstract
- SSHKit::EC2InstanceConnect::Backend
- Extended by:
- Forwardable
- Defined in:
- lib/sshkit/ec2instanceconnect/backend.rb
Overview
SSHKit backend that integrates with EC2 Instance Connect.
It ensures that SSH keys are automatically created and send to the server before executing any command. It also ensures a timely refresh of the SSH key before it expires.
Constant Summary collapse
- EXPIRES_IN =
SSH keys using EC2 Instance Connect are valid for 60 seconds, so refresh them a bit earlier.
50
Class Attribute Summary collapse
-
.ssh_keys ⇒ Object
Returns the value of attribute ssh_keys.
-
.tunnels ⇒ Object
Returns the value of attribute tunnels.
Class Method Summary collapse
Instance Method Summary collapse
- #download!(remote, local = nil, options = {}) ⇒ Object
- #execute_command(cmd) ⇒ Object
-
#initialize(host) ⇒ Backend
constructor
A new instance of Backend.
- #upload!(local, remote, options = {}) ⇒ Object
Constructor Details
#initialize(host) ⇒ Backend
Returns a new instance of Backend.
38 39 40 41 |
# File 'lib/sshkit/ec2instanceconnect/backend.rb', line 38 def initialize(host, &) super @backend = SSHKit::Backend::Netssh.new(host) end |
Class Attribute Details
.ssh_keys ⇒ Object
Returns the value of attribute ssh_keys.
29 30 31 |
# File 'lib/sshkit/ec2instanceconnect/backend.rb', line 29 def ssh_keys @ssh_keys end |
.tunnels ⇒ Object
Returns the value of attribute tunnels.
29 30 31 |
# File 'lib/sshkit/ec2instanceconnect/backend.rb', line 29 def tunnels @tunnels end |
Class Method Details
.configure ⇒ Object
43 44 45 |
# File 'lib/sshkit/ec2instanceconnect/backend.rb', line 43 def self.configure(&) SSHKit::Backend::Netssh.configure(&) end |
Instance Method Details
#download!(remote, local = nil, options = {}) ⇒ Object
52 53 54 55 |
# File 'lib/sshkit/ec2instanceconnect/backend.rb', line 52 def download!(remote, local = nil, = {}) ensure_connection @backend.send(:download!, remote, local, ) end |
#execute_command(cmd) ⇒ Object
57 58 59 60 |
# File 'lib/sshkit/ec2instanceconnect/backend.rb', line 57 def execute_command(cmd) ensure_connection @backend.send(:execute_command, cmd) end |
#upload!(local, remote, options = {}) ⇒ Object
47 48 49 50 |
# File 'lib/sshkit/ec2instanceconnect/backend.rb', line 47 def upload!(local, remote, = {}) ensure_connection @backend.send(:upload!, local, remote, ) end |