Class: SSHKit::EC2InstanceConnect::SSHKey
- Inherits:
-
Object
- Object
- SSHKit::EC2InstanceConnect::SSHKey
- Defined in:
- lib/sshkit/ec2instanceconnect/ssh_key.rb
Overview
Generate a private/public SSH keypair.
Instance Method Summary collapse
-
#initialize(size:) ⇒ SSHKey
constructor
A new instance of SSHKey.
- #private_key ⇒ Object
- #public_key ⇒ Object
Constructor Details
#initialize(size:) ⇒ SSHKey
Returns a new instance of SSHKey.
10 11 12 |
# File 'lib/sshkit/ec2instanceconnect/ssh_key.rb', line 10 def initialize(size:) @key = OpenSSL::PKey::RSA.generate(size) end |
Instance Method Details
#private_key ⇒ Object
14 15 16 |
# File 'lib/sshkit/ec2instanceconnect/ssh_key.rb', line 14 def private_key @key.to_pem end |
#public_key ⇒ Object
18 19 20 21 22 23 |
# File 'lib/sshkit/ec2instanceconnect/ssh_key.rb', line 18 def public_key blob = @key.public_key.to_blob encoded = [blob].pack('m0') "ssh-rsa #{encoded}" end |