Class: Dcmgr::Models::SshKeyPair
Overview
SSH Key database for account.
Constant Summary
Constants inherited
from BaseNew
BaseNew::LOCK_TABLES_KEY
Class Method Summary
collapse
Instance Method Summary
collapse
#account
Methods inherited from BaseNew
Proxy, dataset, default_row_lock_mode=, install_data, install_data_hooks, lock!, unlock!, #with_timestamps?
Class Method Details
.generate_key_pair ⇒ Hash
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
|
# File 'lib/dcmgr/models/ssh_key_pair.rb', line 31
def self.generate_key_pair()
pkey = File.expand_path(randstr, Dir.tmpdir)
pubkey = pkey + '.pub'
begin
system("ssh-keygen -q -t rsa -C '' -N '' -f %s >/dev/null" % [pkey])
unless $?.exitstatus == 0
raise "Failed to run ssh-keygen: exitcode=#{$?.exitstatus}"
end
fp = `ssh-keygen -l -f #{pkey}`
unless $?.exitstatus == 0
raise "Failed to collect finger print value"
end
fp = fp.split(/\s+/)[1]
{:private_key=>IO.read(pkey),
:public_key=>IO.read(pubkey),
:finger_print => fp}
rescue
[pkey, pubkey].each { |i|
File.unlink(i) if File.exist?(i)
}
end
end
|
Instance Method Details
#before_destroy ⇒ Object
23
24
25
26
|
# File 'lib/dcmgr/models/ssh_key_pair.rb', line 23
def before_destroy
end
|
#to_api_document ⇒ Object
58
59
60
|
# File 'lib/dcmgr/models/ssh_key_pair.rb', line 58
def to_api_document
to_hash
end
|
#validate ⇒ Object
20
21
|
# File 'lib/dcmgr/models/ssh_key_pair.rb', line 20
def validate
end
|