Module: Awsome::Ssh
- Defined in:
- lib/awsome/ssh.rb
Class Method Summary collapse
- .ensure_ssh_env_vars! ⇒ Object
- .has_ssh?(host) ⇒ Boolean
- .scp(from, to) ⇒ Object
- .ssh(host, *scripts) ⇒ Object
Class Method Details
.ensure_ssh_env_vars! ⇒ Object
3 4 5 6 |
# File 'lib/awsome/ssh.rb', line 3 def self.ensure_ssh_env_vars! raise 'SSH_KEY environment variable not set' if ENV['SSH_KEY'].nil? raise 'SSH_USER environment varibale not set' if ENV['SSH_USER'].nil? end |
.has_ssh?(host) ⇒ Boolean
23 24 25 |
# File 'lib/awsome/ssh.rb', line 23 def self.has_ssh?(host) Awsome.execute("nc -zw 2 #{host} 22 < /dev/null", system: true, verbose: false) end |
.scp(from, to) ⇒ Object
13 14 15 16 17 18 19 20 21 |
# File 'lib/awsome/ssh.rb', line 13 def self.scp(from, to) ensure_ssh_env_vars! if File.exists?(from) to = "#{ENV['SSH_USER']}@#{to}" else from = "#{ENV['SSH_USER']}@#{from}" end Awsome.execute("scp -i #{ENV['SSH_KEY']} #{from} #{to}", system: true, verbose: false) end |