-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
16 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,13 +30,27 @@ k = SSHKey.generate( | |
|
||
### Use your existing key | ||
|
||
Return an SSHKey object from an existing RSA or DSA or ECDSA private key (provided as a string). | ||
Return an SSHKey object from an existing RSA or DSA or ECDSA private key (provided as a string in PEM format). | ||
|
||
```ruby | ||
f = File.read(File.expand_path("~/.ssh/id_rsa")) | ||
k = SSHKey.new(f, comment: "[email protected]") | ||
``` | ||
|
||
If your existing key is in the OpenSSH format (starts with `-----BEGIN OPENSSH PRIVATE KEY-----`), you'll need to convert it to PEM format or generate a new key. | ||
|
||
Generate a new RSA key in PEM format with `ssh-keygen`: | ||
|
||
``` | ||
ssh-keygen -t rsa -b 4096 -m PEM | ||
``` | ||
|
||
Or convert an existing OpenSSH-formatted key with the following. This will modify the existing private key file. | ||
|
||
``` | ||
ssh-keygen -p -N "" -m pem -f /path/to/existing/private/key | ||
``` | ||
|
||
### The SSHKey object | ||
|
||
#### Private and public keys | ||
|
@@ -159,7 +173,7 @@ puts k.randomart | |
|
||
#### Original OpenSSL key object | ||
|
||
Return the original [OpenSSL::PKey::RSA](https://ruby-doc.org/3.2.2/exts/openssl/OpenSSL/PKey/RSA.html) or [OpenSSL::PKey::DSA](https://ruby-doc.org/3.2.2/exts/openssl/OpenSSL/PKey/DSA.html) or [OpenSSL::PKey::EC](https://ruby-doc.org/3.2.2/exts/openssl/OpenSSL/PKey/EC.html)object. | ||
Return the original [OpenSSL::PKey::RSA](https://ruby-doc.org/3.2.2/exts/openssl/OpenSSL/PKey/RSA.html) or [OpenSSL::PKey::DSA](https://ruby-doc.org/3.2.2/exts/openssl/OpenSSL/PKey/DSA.html) or [OpenSSL::PKey::EC](https://ruby-doc.org/3.2.2/exts/openssl/OpenSSL/PKey/EC.html) object. | ||
|
||
```ruby | ||
k.key_object | ||
|