Class: CloudRunner::SshKey
- Inherits:
-
Object
- Object
- CloudRunner::SshKey
- Defined in:
- lib/cloud_runner/ssh_key.rb
Instance Attribute Summary collapse
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Instance Method Summary collapse
-
#initialize(type = "rsa", private_path = nil) ⇒ SshKey
constructor
A new instance of SshKey.
- #private ⇒ Object
- #private_path ⇒ Object
- #public ⇒ Object
Constructor Details
#initialize(type = "rsa", private_path = nil) ⇒ SshKey
Returns a new instance of SshKey.
7 8 9 10 |
# File 'lib/cloud_runner/ssh_key.rb', line 7 def initialize(type="rsa", private_path=nil) raise "Type must be specified" unless @type = type @private_path = private_path end |
Instance Attribute Details
#type ⇒ Object (readonly)
Returns the value of attribute type.
5 6 7 |
# File 'lib/cloud_runner/ssh_key.rb', line 5 def type @type end |
Instance Method Details
#private ⇒ Object
16 17 18 |
# File 'lib/cloud_runner/ssh_key.rb', line 16 def private File.read(private_path) end |
#private_path ⇒ Object
20 21 22 23 24 25 26 |
# File 'lib/cloud_runner/ssh_key.rb', line 20 def private_path unless @private_path @private_path = "/tmp/ssh-key-#{SecureRandom.hex}" generate end @private_path end |
#public ⇒ Object
12 13 14 |
# File 'lib/cloud_runner/ssh_key.rb', line 12 def public File.read("#{private_path}.pub") end |