sshman 0.3.1 → 0.3.2
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/lib/sshman/cli.rb +6 -1
- data/lib/sshman/key_manager.rb +38 -0
- data/lib/sshman/version.rb +1 -1
- metadata +10 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7d12769822a842e3ec98115729fbf351cd75f03e0ae53c49c54b2a13b71244fd
|
4
|
+
data.tar.gz: bd84b232c52e2f24596c92addb1fc28b682fc9e6b48d5bb45ba074ec1912aafc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0b2503b2800696599505134a309163732628c718a3b71ee5f072cb658f4b3909d818aae5002a4727b987f956e3f34c59fa07921f2cecf089a00b32ba5fd86aa9
|
7
|
+
data.tar.gz: 877cbdd15680f0dc88b5e1c642c91b455c64a5661968797680c245ee4e1bdb4c1564daea471a3fd6683599457a643310b270dbce41126075b705ccd865cbc4f4
|
data/lib/sshman/cli.rb
CHANGED
@@ -3,6 +3,7 @@ require_relative 'constants'
|
|
3
3
|
require_relative 'version'
|
4
4
|
require_relative 'server_manager'
|
5
5
|
require_relative 'utils'
|
6
|
+
require_relative 'key_manager'
|
6
7
|
|
7
8
|
module Sshman
|
8
9
|
class CLI
|
@@ -20,6 +21,8 @@ module Sshman
|
|
20
21
|
new.delete_server
|
21
22
|
when 'connect'
|
22
23
|
new.connect_to_server(argv[1])
|
24
|
+
when 'generate_key'
|
25
|
+
KeyManager.generate_key
|
23
26
|
when 'help'
|
24
27
|
new.display_help
|
25
28
|
when 'version'
|
@@ -41,7 +44,7 @@ module Sshman
|
|
41
44
|
ensure_csv_file
|
42
45
|
|
43
46
|
loop do
|
44
|
-
puts "\n#{YELLOW}Options:#{RESET_COLOR} list, add, edit, delete, connect, help, quit"
|
47
|
+
puts "\n#{YELLOW}Options:#{RESET_COLOR} list, add, edit, delete, connect, generate_key, help, quit"
|
45
48
|
print "#{CYAN}Choose an option: #{RESET_COLOR}"
|
46
49
|
option = gets.chomp.downcase.strip
|
47
50
|
|
@@ -56,6 +59,8 @@ module Sshman
|
|
56
59
|
delete_server
|
57
60
|
when 'connect'
|
58
61
|
connect_to_server
|
62
|
+
when 'generate_key'
|
63
|
+
KeyManager.generate_key
|
59
64
|
when 'help'
|
60
65
|
display_help
|
61
66
|
when 'quit'
|
@@ -0,0 +1,38 @@
|
|
1
|
+
require 'openssl'
|
2
|
+
require 'fileutils'
|
3
|
+
|
4
|
+
module Sshman
|
5
|
+
class KeyManager
|
6
|
+
SSH_DIR = File.expand_path("~/.ssh")
|
7
|
+
|
8
|
+
def self.generate_key
|
9
|
+
FileUtils.mkdir_p(SSH_DIR)
|
10
|
+
|
11
|
+
print "Enter bit size (default 2048): "
|
12
|
+
bit_size = gets.chomp.to_i
|
13
|
+
bit_size = 2048 if bit_size <= 0
|
14
|
+
|
15
|
+
print "Enter key name (default id_rsa): "
|
16
|
+
key_name = gets.chomp.strip
|
17
|
+
key_name = "id_rsa" if key_name.empty?
|
18
|
+
|
19
|
+
private_key_path = File.join(SSH_DIR, key_name)
|
20
|
+
public_key_path = "#{private_key_path}.pub"
|
21
|
+
|
22
|
+
print "Enter passphrase (leave blank for no passphrase): "
|
23
|
+
passphrase = gets.chomp.strip
|
24
|
+
|
25
|
+
key = OpenSSL::PKey::RSA.new(bit_size)
|
26
|
+
cipher = OpenSSL::Cipher.new('AES-128-CBC') if passphrase != ""
|
27
|
+
private_key = passphrase.empty? ? key.to_pem : key.export(cipher, passphrase)
|
28
|
+
public_key = "ssh-rsa #{[key.public_key.to_der].pack('m0')}"
|
29
|
+
|
30
|
+
File.write(private_key_path, private_key)
|
31
|
+
File.write(public_key_path, public_key)
|
32
|
+
File.chmod(0600, private_key_path)
|
33
|
+
File.chmod(0644, public_key_path)
|
34
|
+
|
35
|
+
puts "#{GREEN}SSH keys generated successfully! Private key: #{private_key_path}, Public key: #{public_key_path}#{RESET_COLOR}"
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
data/lib/sshman/version.rb
CHANGED
metadata
CHANGED
@@ -1,19 +1,19 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sshman
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- SubnetMasked
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-10-
|
11
|
+
date: 2024-10-05 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: A simple terminal-based SSH manager to add, list, delete, and connect
|
14
14
|
to SSH servers.
|
15
15
|
email:
|
16
|
-
- '
|
16
|
+
- 'subnetmasked@cock.li '
|
17
17
|
executables:
|
18
18
|
- sshman
|
19
19
|
extensions: []
|
@@ -22,18 +22,19 @@ files:
|
|
22
22
|
- exe/sshman
|
23
23
|
- lib/sshman/cli.rb
|
24
24
|
- lib/sshman/constants.rb
|
25
|
+
- lib/sshman/key_manager.rb
|
25
26
|
- lib/sshman/server_manager.rb
|
26
27
|
- lib/sshman/sshman.rb
|
27
28
|
- lib/sshman/utils.rb
|
28
29
|
- lib/sshman/version.rb
|
29
30
|
homepage: https://github.com/subnetmasked/sshman
|
30
31
|
licenses:
|
31
|
-
- GPL-3.0
|
32
|
+
- GPL-3.0-or-later
|
32
33
|
metadata:
|
33
34
|
homepage_uri: https://github.com/subnetmasked/sshman
|
34
35
|
source_code_uri: https://github.com/subnetmasked/sshman
|
35
36
|
bug_tracker_uri: https://github.com/subnetmasked/sshman/issues
|
36
|
-
post_install_message:
|
37
|
+
post_install_message:
|
37
38
|
rdoc_options: []
|
38
39
|
require_paths:
|
39
40
|
- lib
|
@@ -41,15 +42,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
41
42
|
requirements:
|
42
43
|
- - ">="
|
43
44
|
- !ruby/object:Gem::Version
|
44
|
-
version:
|
45
|
+
version: 2.5.0
|
45
46
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
46
47
|
requirements:
|
47
48
|
- - ">="
|
48
49
|
- !ruby/object:Gem::Version
|
49
50
|
version: '0'
|
50
51
|
requirements: []
|
51
|
-
rubygems_version: 3.
|
52
|
-
signing_key:
|
52
|
+
rubygems_version: 3.5.21
|
53
|
+
signing_key:
|
53
54
|
specification_version: 4
|
54
55
|
summary: A terminal-based SSH manager
|
55
56
|
test_files: []
|