ssh_key_switcher 1.0.4 → 1.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +24 -2
- data/lib/ssh_key_switcher/options/ping.rb +4 -1
- data/lib/ssh_key_switcher/options/select.rb +4 -2
- data/lib/ssh_key_switcher/utils/cmd.rb +1 -5
- data/lib/ssh_key_switcher/utils/helper.rb +1 -1
- data/lib/ssh_key_switcher/utils/ssh_agent.rb +9 -0
- data/lib/ssh_key_switcher/version.rb +1 -1
- data/lib/ssh_key_switcher.rb +1 -0
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e2ad23e81673482e19d3eae55c0b787ef26f1dfd3f1d1e213a1c10039495478d
|
4
|
+
data.tar.gz: 1f539080d59584e814f18d4732df9e89e1c13c8607b9d5b12de6c30d536b9db4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e294cfbab8f108aa2138b780636ae58ef0686b8a62554c8d986b3d621379c56e3f03644e1a778616b727e0259e82562fa02810ad0214009f9d2dd3a84c7e45c6
|
7
|
+
data.tar.gz: 96ff45770f8fe42842fa55466e84cfd3f340bc4e14827ee120605d45b6ce6f7e96d56e26e61af3970b73cd3f6a67e024ed639058011f3407f7dba76778a9e2a2
|
data/README.md
CHANGED
@@ -64,6 +64,15 @@ $ sks -s [--select]
|
|
64
64
|
|
65
65
|
Allows you to interactively select and set an OpenSSH key for your sessions.
|
66
66
|
|
67
|
+
### List of OpenSSH Keys
|
68
|
+
|
69
|
+
```bash
|
70
|
+
$ sks -l [--list]
|
71
|
+
|
72
|
+
```
|
73
|
+
|
74
|
+
Display a list of OpenSSH keys.
|
75
|
+
|
67
76
|
### List Active OpenSSH Keys
|
68
77
|
|
69
78
|
```bash
|
@@ -92,10 +101,23 @@ The gem is available as open source under the terms of the [MIT License](https:/
|
|
92
101
|
|
93
102
|
## Development
|
94
103
|
|
95
|
-
|
104
|
+
**Debug**
|
96
105
|
|
97
|
-
|
106
|
+
```bash
|
107
|
+
bundle exec sks [option]
|
108
|
+
```
|
98
109
|
|
110
|
+
**Install locally to test**
|
111
|
+
|
112
|
+
```bash
|
113
|
+
bin/install-local [version]
|
114
|
+
```
|
115
|
+
|
116
|
+
**Release**
|
117
|
+
|
118
|
+
```bash
|
119
|
+
bin/release [version]
|
120
|
+
```
|
99
121
|
|
100
122
|
## Contributor
|
101
123
|
|
@@ -7,7 +7,10 @@ module SshKeySwitcher
|
|
7
7
|
def pong
|
8
8
|
server_names = SERVER_NAMES.map { |server| "git@#{server}" }
|
9
9
|
result = prompt.select('Connect to', server_names, default: 'git@github.com')
|
10
|
-
Cmd.exec("ssh -T #{result}"
|
10
|
+
stdout, stderr, status = Cmd.exec("ssh -T #{result}")
|
11
|
+
return prompt.ok(stdout) if status.success?
|
12
|
+
|
13
|
+
prompt.error(stderr)
|
11
14
|
end
|
12
15
|
|
13
16
|
private
|
@@ -21,8 +21,10 @@ module SshKeySwitcher
|
|
21
21
|
return if path_open_ssh_key.nil?
|
22
22
|
|
23
23
|
SshKeySwitcher::Utils::SshAgent.remove_all
|
24
|
-
SshKeySwitcher::Utils::SshAgent.add(path_open_ssh_key)
|
25
|
-
prompt.ok('OpenSSH key
|
24
|
+
_stdout, stderr, status = SshKeySwitcher::Utils::SshAgent.add(path_open_ssh_key)
|
25
|
+
return prompt.ok('Add OpenSSH key successfully!') if status.success?
|
26
|
+
|
27
|
+
prompt.error(stderr)
|
26
28
|
end
|
27
29
|
|
28
30
|
private
|
@@ -7,12 +7,8 @@ module SshKeySwitcher
|
|
7
7
|
module Cmd
|
8
8
|
module_function
|
9
9
|
|
10
|
-
def exec(command,
|
10
|
+
def exec(command, _opts = {})
|
11
11
|
stdout, stderr, status = Open3.capture3(command)
|
12
|
-
if opts[:print]
|
13
|
-
print stderr
|
14
|
-
print stdout
|
15
|
-
end
|
16
12
|
[stdout, stderr, status]
|
17
13
|
end
|
18
14
|
end
|
@@ -15,7 +15,7 @@ module SshKeySwitcher
|
|
15
15
|
|
16
16
|
def fetch_private_ssh_keys_via_header
|
17
17
|
ssh_dir = File.expand_path(SSH_DIR)
|
18
|
-
|
18
|
+
Dir.glob("#{ssh_dir}/**/*").select do |file|
|
19
19
|
next if File.directory?(file)
|
20
20
|
|
21
21
|
File.open(file, 'rb') do |f|
|
@@ -3,6 +3,10 @@
|
|
3
3
|
module SshKeySwitcher
|
4
4
|
module Utils
|
5
5
|
class SshAgent
|
6
|
+
def self.start_ssh_agent
|
7
|
+
Cmd.exec('eval $(ssh-agent -s)')
|
8
|
+
end
|
9
|
+
|
6
10
|
def self.add(private_key)
|
7
11
|
Cmd.exec("ssh-add #{private_key}")
|
8
12
|
end
|
@@ -14,6 +18,11 @@ module SshKeySwitcher
|
|
14
18
|
def self.del(path)
|
15
19
|
Cmd.exec("ssh-add -d #{path}")
|
16
20
|
end
|
21
|
+
|
22
|
+
def self.start_ssh_agent_if_needed
|
23
|
+
ssh_agent_pid = ENV.fetch('SSH_AGENT_PID', nil)
|
24
|
+
start_ssh_agent if ssh_agent_pid.nil? || !system("ps -p #{ssh_agent_pid} > /dev/null 2>&1")
|
25
|
+
end
|
17
26
|
end
|
18
27
|
end
|
19
28
|
end
|
data/lib/ssh_key_switcher.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ssh_key_switcher
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Minh Tang Q.
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-08-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|
@@ -84,7 +84,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
84
84
|
- !ruby/object:Gem::Version
|
85
85
|
version: '0'
|
86
86
|
requirements: []
|
87
|
-
rubygems_version: 3.
|
87
|
+
rubygems_version: 3.4.6
|
88
88
|
signing_key:
|
89
89
|
specification_version: 4
|
90
90
|
summary: A simple and efficient for managing and switching between OpenSSH keys seamlessly
|