Class: Scro::Auth::Key
- Inherits:
-
Object
- Object
- Scro::Auth::Key
- Defined in:
- lib/scro/auth/key.rb
Instance Method Summary collapse
- #ensure_ssh_keygen_present ⇒ Object
- #generate ⇒ Object
-
#initialize(keygen = 'ssh-keygen') ⇒ Key
constructor
A new instance of Key.
- #private_key ⇒ Object
- #public_key ⇒ Object
- #stderr ⇒ Object
- #stdout(suffix = 'out') ⇒ Object
Constructor Details
#initialize(keygen = 'ssh-keygen') ⇒ Key
Returns a new instance of Key.
4 5 6 7 8 9 |
# File 'lib/scro/auth/key.rb', line 4 def initialize(keygen = 'ssh-keygen') @keygen = keygen @filename = Digest::SHA1.hexdigest(Time.now.to_f.to_s) generate end |
Instance Method Details
#ensure_ssh_keygen_present ⇒ Object
16 17 18 19 |
# File 'lib/scro/auth/key.rb', line 16 def ensure_ssh_keygen_present `which #{@keygen}` raise ArgumentError, "Unable to find the ssh-keygen executable" unless $?.success? end |
#generate ⇒ Object
11 12 13 14 |
# File 'lib/scro/auth/key.rb', line 11 def generate ensure_ssh_keygen_present `#{@keygen} -f #{private_key} -P '' > #{stdout} 2>#{stderr}` end |
#private_key ⇒ Object
21 22 23 |
# File 'lib/scro/auth/key.rb', line 21 def private_key "#{Dir.tmpdir}/#{@filename}" end |
#public_key ⇒ Object
25 26 27 |
# File 'lib/scro/auth/key.rb', line 25 def public_key "#{private_key}.pub" end |
#stderr ⇒ Object
29 30 31 |
# File 'lib/scro/auth/key.rb', line 29 def stderr stdout('error') end |
#stdout(suffix = 'out') ⇒ Object
33 34 35 |
# File 'lib/scro/auth/key.rb', line 33 def stdout(suffix = 'out') "#{private_key}.#{suffix}.log" end |