class Shelly::SshKey

Attributes

path[R]

Public Class Methods

new(path) click to toggle source
# File lib/shelly/ssh_key.rb, line 4
def initialize(path)
  @path = File.expand_path(path)
end

Public Instance Methods

destroy() click to toggle source
# File lib/shelly/ssh_key.rb, line 12
def destroy
  shelly.delete_ssh_key(fingerprint) if uploaded?
end
exists?() click to toggle source
# File lib/shelly/ssh_key.rb, line 8
def exists?
  File.exists?(path)
end
fingerprint() click to toggle source
# File lib/shelly/ssh_key.rb, line 28
def fingerprint
  `ssh-keygen -lf #{path}`.split(" ")[1]
end
key() click to toggle source
# File lib/shelly/ssh_key.rb, line 32
def key
  File.read(path)
end
upload() click to toggle source
# File lib/shelly/ssh_key.rb, line 16
def upload
  shelly.add_ssh_key(key)
end
uploaded?() click to toggle source
# File lib/shelly/ssh_key.rb, line 20
def uploaded?
  return false unless exists?
  shelly.ssh_key(fingerprint)
  true
rescue Shelly::Client::NotFoundException
  false
end