Sha256: 6bc333eef5220800550c5128130cc31460114eef67975443fb2c1c9f040e6461
Contents?: true
Size: 1.34 KB
Versions: 12
Compression:
Stored size: 1.34 KB
Contents
require 'mj/tools/subprocess.rb' module MJ; module Tools class SSH include MJ::Tools::SubProcess @keys_added = [] def self.add_key( key_file ) if @keys_added.index( key_file ) return end if ssh_add( "#{key_file}" ) == 0 @keys_added << key_file end end def self.cleanup @keys_added.each do |file| self.remove_key( file ) end @keys_added = [] end def self.has_key?( key_file ) if @keys_added.index( key_file ) return true end found = false ssh_add '-l' do |line| if line.index(key_file) return found = true end end return found end def self.remove_key( key_file ) ssh_add( "-d #{key_file}" ) end def self.remove_all_keys ssh_add( "-D" ) end def self.list_keys ssh_add( "-l" ) end def self.ssh_add( command, &block ) if block_given? self.execute "ssh-add #{command}", &block else self.execute "ssh-add #{command}" end end end end; end
Version data entries
12 entries across 12 versions & 1 rubygems