Module: Billy::Util::Ssh

Defined in:
lib/billy/util/ssh.rb

Class Method Summary collapse

Class Method Details

.get_pub_key(type = :id_rsa) ⇒ Object



14
15
16
17
18
# File 'lib/billy/util/ssh.rb', line 14

def get_pub_key( type = :id_rsa )
  keys = pub_keys
  return nil unless !keys.nil? && keys.any?
  keys[ type ]
end

.pub_keysObject



20
21
22
23
24
25
26
27
28
# File 'lib/billy/util/ssh.rb', line 20

def pub_keys
  return nil unless ssh_folder_exists?
  res = Hash.new
  Dir[ ssh_root_path + '/*.pub' ].each do |f|
    key = File.basename( f, '.pub' ).to_sym
    res[ key ] = File.read( f )
  end
  res
end

.ssh_folder_exists?Boolean

Returns:

  • (Boolean)


10
11
12
# File 'lib/billy/util/ssh.rb', line 10

def ssh_folder_exists?
  File.exists?( ssh_root_path ) && File.directory?( ssh_root_path )
end

.ssh_root_pathObject



6
7
8
# File 'lib/billy/util/ssh.rb', line 6

def ssh_root_path
  File.expand_path( "~/.ssh" )
end