class Locum::Ssh
Public Instance Methods
add_ssh_key(key_file)
click to toggle source
# File lib/locum/ssh.rb, line 5 def add_ssh_key(key_file) @key = File.read(key_file).strip run_on_server("mkdir .ssh") run_on_server("echo #{@key} >> .ssh/authorized_keys") end
hu()
click to toggle source
# File lib/locum/ssh.rb, line 12 def hu @hu ||= Locum::HostingUnit.get end
Private Instance Methods
run_on_server(cmd)
click to toggle source
# File lib/locum/ssh.rb, line 18 def run_on_server(cmd) begin Net::SSH.start(hu.server, hu.login, :password => hu.password) do |ssh| ssh.exec!(cmd) end rescue Net::SSH::HostKeyMismatch => e e.remember_host! retry rescue StandardError => e raise ApiError, e.to_s end end