spectre-ssh 1.0.1 → 1.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/spectre/ssh.rb +24 -10
- metadata +43 -15
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 180b0db0cfa9d88522b4f4147f5b2e2e2bdb2c9da4743d6fac85599f71769ea6
|
4
|
+
data.tar.gz: 7b65847ee82c04053f4ad6d1bc91aab8aa92aada3703505027bb3167a35bd5fd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 907a71a63ac527f78b981c5dde110ce5914361685195d7827d23e6d716dbeea7402dadbbe849e0cb13c3b63ebcb01a5c26a76fac3be14109d99ddca20858147e
|
7
|
+
data.tar.gz: 1b9031c4c95d3773fe1b8fe83f310149a3c07226cc66ddce63efffabae98c27b745d54db774e80cb7801c98db298cc8139ce184508dd7ec685d767a2b5f5eb29
|
data/lib/spectre/ssh.rb
CHANGED
@@ -7,6 +7,12 @@ module Spectre
|
|
7
7
|
module SSH
|
8
8
|
@@cfg = {}
|
9
9
|
|
10
|
+
class SSHError < Exception
|
11
|
+
def initialize message
|
12
|
+
super message
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
10
16
|
class SSHConnection < Spectre::DslClass
|
11
17
|
def initialize host, username, opts, logger
|
12
18
|
opts[:non_interactive] = true
|
@@ -32,7 +38,13 @@ module Spectre
|
|
32
38
|
|
33
39
|
def connect!
|
34
40
|
return unless @__session == nil or @__session.closed?
|
35
|
-
|
41
|
+
begin
|
42
|
+
@__session = Net::SSH.start(@__host, @__username, @__opts)
|
43
|
+
rescue SocketError
|
44
|
+
raise SSHError.new("Unable to connect to #{@__host} with user #{@__username}")
|
45
|
+
rescue Net::SSH::AuthenticationFailed
|
46
|
+
raise SSHError.new("Authentication failed for #{@__username}@#{@__host}. Please check password, SSH keys and passphrases.")
|
47
|
+
end
|
36
48
|
end
|
37
49
|
|
38
50
|
def close
|
@@ -106,24 +118,26 @@ module Spectre
|
|
106
118
|
|
107
119
|
|
108
120
|
class << self
|
109
|
-
def ssh name,
|
110
|
-
raise "SSH connection '#{name}' not configured" unless @@cfg.key?(name) or
|
121
|
+
def ssh name, options = {}, &block
|
122
|
+
raise "SSH connection '#{name}' not configured" unless @@cfg.key?(name) or options.count > 0
|
111
123
|
|
112
124
|
cfg = @@cfg[name] || {}
|
113
125
|
|
114
126
|
host = cfg['host'] || name
|
115
|
-
username =
|
116
|
-
password =
|
127
|
+
username = options[:username] || cfg['username']
|
128
|
+
password = options[:password] || cfg['password']
|
117
129
|
|
118
130
|
opts = {}
|
119
131
|
opts[:password] = password
|
120
|
-
opts[:port] =
|
121
|
-
|
122
|
-
|
132
|
+
opts[:port] = options[:port] || cfg['port'] || 22
|
133
|
+
|
134
|
+
ssh_key = options[:key] || cfg['key']
|
135
|
+
opts[:keys] = [ssh_key] unless ssh_key.nil?
|
136
|
+
opts[:passphrase] = options[:passphrase] || cfg['passphrase']
|
123
137
|
|
124
138
|
opts[:auth_methods] = []
|
125
|
-
opts[:auth_methods].push 'publickey'
|
126
|
-
opts[:auth_methods].push 'password'
|
139
|
+
opts[:auth_methods].push 'publickey' unless opts[:keys].nil? or opts[:keys].empty?
|
140
|
+
opts[:auth_methods].push 'password' unless opts[:password].nil?
|
127
141
|
|
128
142
|
ssh_con = SSHConnection.new(host, username, opts, @@logger)
|
129
143
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: spectre-ssh
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Christian Neubauer
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-05-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: openssl
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
19
|
+
version: 3.0.0
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version:
|
26
|
+
version: 3.0.0
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: net-ssh
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -44,31 +44,59 @@ dependencies:
|
|
44
44
|
requirements:
|
45
45
|
- - ">="
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: 1.8.
|
47
|
+
version: 1.8.0
|
48
48
|
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: 1.8.
|
54
|
+
version: 1.8.0
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: ed25519
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 1.3.0
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: 1.3.0
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: bcrypt_pbkdf
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: 1.1.0
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: 1.1.0
|
55
83
|
description: Adds SSH access functionality to the spectre framework
|
56
84
|
email:
|
57
|
-
-
|
85
|
+
- christian.neubauer@ionos.com
|
58
86
|
executables: []
|
59
87
|
extensions: []
|
60
88
|
extra_rdoc_files: []
|
61
89
|
files:
|
62
90
|
- lib/spectre/ssh.rb
|
63
|
-
homepage: https://github.com/
|
91
|
+
homepage: https://github.com/ionos-spectre/spectre-ssh
|
64
92
|
licenses:
|
65
93
|
- MIT
|
66
94
|
metadata:
|
67
95
|
allowed_push_host: https://rubygems.org/
|
68
|
-
homepage_uri: https://github.com/
|
69
|
-
source_code_uri: https://github.com/
|
70
|
-
changelog_uri: https://github.com/
|
71
|
-
post_install_message:
|
96
|
+
homepage_uri: https://github.com/ionos-spectre/spectre-ssh
|
97
|
+
source_code_uri: https://github.com/ionos-spectre/spectre-ssh
|
98
|
+
changelog_uri: https://github.com/ionos-spectre/spectre-ssh/blob/master/CHANGELOG.md
|
99
|
+
post_install_message:
|
72
100
|
rdoc_options: []
|
73
101
|
require_paths:
|
74
102
|
- lib
|
@@ -83,8 +111,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
83
111
|
- !ruby/object:Gem::Version
|
84
112
|
version: '0'
|
85
113
|
requirements: []
|
86
|
-
rubygems_version: 3.
|
87
|
-
signing_key:
|
114
|
+
rubygems_version: 3.3.7
|
115
|
+
signing_key:
|
88
116
|
specification_version: 4
|
89
117
|
summary: SSH module for spectre
|
90
118
|
test_files: []
|