ssh-short 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +8 -4
- data/lib/ssh_short/keyset.rb +21 -7
- data/lib/ssh_short/version.rb +1 -1
- data/spec/ssh_short/keyset_spec.rb +8 -8
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA512:
|
3
|
-
data.tar.gz:
|
4
|
-
metadata.gz:
|
3
|
+
data.tar.gz: 013894983677178843ed84e84de179db2646b94851fbb8352bec508d392d0bef9f4473178cf6bb9170f8882ba2dc6173f45cf1673236be8e7794631e81d565cd
|
4
|
+
metadata.gz: f0950a8ffdcdbcbe3f69fe3b92d34d9be9f69aa713d76d5459f36794c2a87ab43ececc0660b4de31632d5645cb57bfa030e7eb17c650d10038590baa224a4c45
|
5
5
|
SHA1:
|
6
|
-
data.tar.gz:
|
7
|
-
metadata.gz:
|
6
|
+
data.tar.gz: 31394bed9beb69c61f3cfc15142abe3ed88d1e7f
|
7
|
+
metadata.gz: 9ae918535b15ed6c1ea250f7b12d9902bdb12820
|
data/README.md
CHANGED
@@ -69,12 +69,15 @@ You can override the user for a node, see args section below
|
|
69
69
|
When you connect to a host for the first time with ssh-short, it will scan your `keys_dir`
|
70
70
|
and present you with a list of numbered keys:
|
71
71
|
|
72
|
+
**Update:** As of version 0.2.0 your default SSH Key (`id_rsa`) can now be used and will be presented as option `0`
|
73
|
+
|
72
74
|
```
|
73
75
|
user@localhost $ sshort 16
|
74
76
|
Select a key:
|
75
|
-
0)
|
76
|
-
1)
|
77
|
-
2)
|
77
|
+
0) id_rsa
|
78
|
+
1) Dev.pem
|
79
|
+
2) Test.pem
|
80
|
+
3) Admin.pem
|
78
81
|
```
|
79
82
|
|
80
83
|
Simply type the number of the key and press enter. ssh-short will connect you via `ssh`,
|
@@ -114,7 +117,8 @@ This forces an update to the key for a node and you will be presented with the l
|
|
114
117
|
```
|
115
118
|
user@localhost $ sshort 16 -k
|
116
119
|
Select a key:
|
117
|
-
0)
|
120
|
+
0) id_rsa
|
121
|
+
1) Dev.pem
|
118
122
|
...
|
119
123
|
```
|
120
124
|
|
data/lib/ssh_short/keyset.rb
CHANGED
@@ -9,11 +9,7 @@ module SshShort
|
|
9
9
|
end
|
10
10
|
|
11
11
|
def prompt_for_key
|
12
|
-
|
13
|
-
keys = Dir.glob("#{@keys_dir}/*").select{ |e| File.file? e }
|
14
|
-
abort "Error: No keys found in #{@keys_dir}" unless keys.count > 0
|
15
|
-
|
16
|
-
key_names = keys.collect { |key| File.basename key }
|
12
|
+
key_names = find_keys.collect { |key| File.basename key }
|
17
13
|
key_names.unshift 'id_rsa'
|
18
14
|
|
19
15
|
puts 'Select a key:'
|
@@ -26,11 +22,29 @@ module SshShort
|
|
26
22
|
end
|
27
23
|
|
28
24
|
def get_key(key_name)
|
29
|
-
|
30
|
-
|
25
|
+
if key_name.eql?('id_rsa')
|
26
|
+
key = File.expand_path('~/.ssh/id_rsa')
|
27
|
+
else
|
28
|
+
keys = find_keys.select { |path| File.basename(path) == key_name }
|
29
|
+
abort "Error: More than one key found called #{key_name}" if keys.count > 1
|
30
|
+
key = keys.first
|
31
|
+
end
|
32
|
+
# key = File.expand_path(key)
|
31
33
|
abort "Error: Cannot find #{key}" unless File.exist? key
|
32
34
|
key
|
33
35
|
end
|
36
|
+
|
37
|
+
def find_keys
|
38
|
+
abort "Error: Cannot find keys directory at #{@keys_dir}" unless File.exist? @keys_dir
|
39
|
+
|
40
|
+
# Recursively search directory, including following symlinks
|
41
|
+
search_string = "#{File.expand_path(@keys_dir)}/**{,/*/**}/*"
|
42
|
+
|
43
|
+
keys = Dir.glob(search_string).select { |e| File.file? e }
|
44
|
+
abort "Error: No keys found in #{@keys_dir}" unless keys.count > 0
|
45
|
+
|
46
|
+
keys
|
47
|
+
end
|
34
48
|
|
35
49
|
end
|
36
50
|
|
data/lib/ssh_short/version.rb
CHANGED
@@ -4,7 +4,12 @@ require 'ssh_short/keyset'
|
|
4
4
|
describe SshShort::KeySet do
|
5
5
|
|
6
6
|
let(:keys_dir) { '/path/to/keys' }
|
7
|
-
let(:keys) { [
|
7
|
+
let(:keys) { [
|
8
|
+
"#{keys_dir}/dir_a/key_a.pem",
|
9
|
+
"#{keys_dir}/dir_a/key_b.pem",
|
10
|
+
"#{keys_dir}/dir_b/key_c.pem",
|
11
|
+
"#{keys_dir}/dir_b/key_d.pem"
|
12
|
+
] }
|
8
13
|
|
9
14
|
subject(:key_set) { SshShort::KeySet.new keys_dir }
|
10
15
|
|
@@ -33,18 +38,15 @@ describe SshShort::KeySet do
|
|
33
38
|
result = key_set.prompt_for_key
|
34
39
|
expect(result).to eq 'id_rsa'
|
35
40
|
end
|
36
|
-
|
37
41
|
end
|
38
|
-
|
39
|
-
|
40
42
|
end
|
41
43
|
|
42
44
|
describe 'get_key' do
|
43
45
|
|
44
46
|
it 'returns the key path from the name' do
|
45
|
-
key_name =
|
47
|
+
key_name = File.basename keys[2] #key_c.pem
|
46
48
|
result = key_set.get_key key_name
|
47
|
-
expect(result).to eq
|
49
|
+
expect(result).to eq keys[2]
|
48
50
|
end
|
49
51
|
|
50
52
|
context 'when the default key name is provided' do
|
@@ -55,8 +57,6 @@ describe SshShort::KeySet do
|
|
55
57
|
end
|
56
58
|
|
57
59
|
end
|
58
|
-
|
59
|
-
|
60
60
|
end
|
61
61
|
|
62
62
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ssh-short
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tom Poulton
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2016-
|
12
|
+
date: 2016-03-15 00:00:00 Z
|
13
13
|
dependencies: []
|
14
14
|
|
15
15
|
description: Easy ssh
|