sshkey 1.2.1 → 1.2.2
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +8 -10
- data/lib/sshkey.rb +3 -2
- data/lib/sshkey/version.rb +1 -1
- metadata +2 -2
data/README.md
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
sshkey
|
2
2
|
======
|
3
3
|
|
4
|
-
Generate private
|
4
|
+
Generate private and public SSH keys (RSA and DSA supported) using Ruby without the `ssh-keygen` system command.
|
5
5
|
|
6
6
|
gem install sshkey
|
7
7
|
|
@@ -10,19 +10,16 @@ Tested on the following Rubies: MRI 1.8.7 and 1.9.2, Rubinius, JRuby. Ruby must
|
|
10
10
|
Usage
|
11
11
|
-----
|
12
12
|
|
13
|
-
|
13
|
+
When generating a new keypair the default key type is 2048-bit RSA, but you can supply the `type` (RSA or DSA) and `bits` in the options.
|
14
|
+
You can also (optionally) supply a comment:
|
14
15
|
|
15
16
|
``` ruby
|
16
|
-
k = SSHKey.generate
|
17
|
-
```
|
18
|
-
|
19
|
-
Generate an SSH DSA Keypair with foo@bar.com as the comment - providing a comment is optional
|
17
|
+
k = SSHKey.generate
|
20
18
|
|
21
|
-
|
22
|
-
k = SSHKey.generate(:type => "dsa", :comment => "foo@bar.com")
|
19
|
+
k = SSHKey.generate(:type => "DSA", :bits => 1024, :comment => "foo@bar.com")
|
23
20
|
```
|
24
21
|
|
25
|
-
Return an SSHKey object from an existing RSA
|
22
|
+
Return an SSHKey object from an existing RSA or DSA private key (provided as a string)
|
26
23
|
|
27
24
|
``` ruby
|
28
25
|
k = SSHKey.new(File.read("~/.ssh/id_rsa"), :comment => "foo@bar.com")
|
@@ -32,7 +29,8 @@ Both of these will return an SSHKey object with the following methods:
|
|
32
29
|
|
33
30
|
``` ruby
|
34
31
|
# Returns an OpenSSL::PKey::RSA or OpenSSL::PKey::DSA key object
|
35
|
-
#
|
32
|
+
# http://www.ruby-doc.org/stdlib/libdoc/openssl/rdoc/classes/OpenSSL/PKey/RSA.html
|
33
|
+
# http://www.ruby-doc.org/stdlib/libdoc/openssl/rdoc/classes/OpenSSL/PKey/DSA.html
|
36
34
|
k.key_object
|
37
35
|
# => -----BEGIN RSA PRIVATE KEY-----\nMIIEowI...
|
38
36
|
|
data/lib/sshkey.rb
CHANGED
@@ -10,9 +10,10 @@ class SSHKey
|
|
10
10
|
|
11
11
|
def self.generate(options = {})
|
12
12
|
type = options[:type] || "rsa"
|
13
|
+
bits = options[:bits] || 2048
|
13
14
|
case type.downcase
|
14
|
-
when "rsa" then SSHKey.new(OpenSSL::PKey::RSA.generate(
|
15
|
-
when "dsa" then SSHKey.new(OpenSSL::PKey::DSA.generate(
|
15
|
+
when "rsa" then SSHKey.new(OpenSSL::PKey::RSA.generate(bits).to_pem, options)
|
16
|
+
when "dsa" then SSHKey.new(OpenSSL::PKey::DSA.generate(bits).to_pem, options)
|
16
17
|
else
|
17
18
|
raise "Unknown key type #{type}"
|
18
19
|
end
|
data/lib/sshkey/version.rb
CHANGED
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: sshkey
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 1.2.
|
5
|
+
version: 1.2.2
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- James Miller
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2011-06-
|
13
|
+
date: 2011-06-04 00:00:00 -07:00
|
14
14
|
default_executable:
|
15
15
|
dependencies: []
|
16
16
|
|