sshkit 1.21.0 → 1.21.3
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/.github/dependabot.yml +16 -0
- data/.github/workflows/push.yml +1 -1
- data/.travis.yml +4 -1
- data/EXAMPLES.md +10 -0
- data/Gemfile +0 -5
- data/Vagrantfile +5 -0
- data/lib/sshkit/backends/connection_pool/cache.rb +12 -5
- data/lib/sshkit/version.rb +1 -1
- data/test/functional/backends/test_netssh.rb +16 -2
- metadata +7 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: aefa716eaeb8369c4f3ab62fce395c84f43d2c8970acaa3d9322c8ab763977c7
|
4
|
+
data.tar.gz: c271da1544ea98cc4df40c00893832f103c165b90c91362a0ae605c3abc3f8be
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 96e66f27d9bd8d3b27708fc219cf965ce8f56a312341fd4e67595649e335686699cf4299947cc34c72bc0e41a0b87f60e954e94910609c1f4f57e921b72f952b
|
7
|
+
data.tar.gz: ee176de7ee2325c91b2b713cee0268e2ad954f3ed07c1412e4b8c81e393dd2f9d4f24394c3aa0d817c6cfb6e8bc605a43546ce85ee24875126a84fc17195416b
|
@@ -0,0 +1,16 @@
|
|
1
|
+
version: 2
|
2
|
+
updates:
|
3
|
+
- package-ecosystem: bundler
|
4
|
+
directory: "/"
|
5
|
+
schedule:
|
6
|
+
interval: monthly
|
7
|
+
open-pull-requests-limit: 10
|
8
|
+
ignore:
|
9
|
+
- dependency-name: rubocop
|
10
|
+
versions:
|
11
|
+
- "> 0.49.1"
|
12
|
+
- package-ecosystem: "github-actions"
|
13
|
+
directory: "/"
|
14
|
+
schedule:
|
15
|
+
interval: monthly
|
16
|
+
open-pull-requests-limit: 10
|
data/.github/workflows/push.yml
CHANGED
data/.travis.yml
CHANGED
data/EXAMPLES.md
CHANGED
@@ -171,6 +171,7 @@ individual hosts:
|
|
171
171
|
SSHKit::Backend::Netssh.configure do |ssh|
|
172
172
|
ssh.connection_timeout = 30
|
173
173
|
ssh.ssh_options = {
|
174
|
+
user: 'adifferentuser',
|
174
175
|
keys: %w(/home/user/.ssh/id_rsa),
|
175
176
|
forward_agent: false,
|
176
177
|
auth_methods: %w(publickey password)
|
@@ -338,6 +339,15 @@ end
|
|
338
339
|
This will resolve the `example.com` hostname into a `SSHKit::Host` object, and
|
339
340
|
try to pull up the correct configuration for it.
|
340
341
|
|
342
|
+
## Connect to a host on a port different than 22
|
343
|
+
|
344
|
+
If your ssh server is running on a port different than 22, you can change this is
|
345
|
+
shown:
|
346
|
+
|
347
|
+
```ruby
|
348
|
+
on('example.com', {port: 1234}) do
|
349
|
+
end
|
350
|
+
```
|
341
351
|
|
342
352
|
## Run a command without it being command-mapped
|
343
353
|
|
data/Gemfile
CHANGED
@@ -2,11 +2,6 @@ source 'https://rubygems.org'
|
|
2
2
|
|
3
3
|
gemspec
|
4
4
|
|
5
|
-
platforms :rbx do
|
6
|
-
gem 'rubysl', '~> 2.0'
|
7
|
-
gem 'json'
|
8
|
-
end
|
9
|
-
|
10
5
|
# public_suffix 3+ requires ruby 2.1+
|
11
6
|
if Gem::Requirement.new('< 2.1').satisfied_by?(Gem::Version.new(RUBY_VERSION))
|
12
7
|
gem 'public_suffix', '< 3'
|
data/Vagrantfile
CHANGED
@@ -2,6 +2,11 @@ VAGRANTFILE_API_VERSION = "2"
|
|
2
2
|
|
3
3
|
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
|
4
4
|
config.vm.box = 'hashicorp/precise64'
|
5
|
+
config.vm.provision "shell", inline: <<-SHELL
|
6
|
+
echo 'ClientAliveInterval 1' >> /etc/ssh/sshd_config
|
7
|
+
echo 'ClientAliveCountMax 1' >> /etc/ssh/sshd_config
|
8
|
+
service ssh restart
|
9
|
+
SHELL
|
5
10
|
|
6
11
|
json_config_path = File.join("test", "boxes.json")
|
7
12
|
list = File.open(json_config_path).read
|
@@ -36,12 +36,12 @@ class SSHKit::Backend::ConnectionPool::Cache
|
|
36
36
|
def evict
|
37
37
|
# Peek at the first connection to see if it is still fresh. If so, we can
|
38
38
|
# return right away without needing to use `synchronize`.
|
39
|
-
first_expires_at,
|
40
|
-
return if first_expires_at.nil? || fresh?(first_expires_at)
|
39
|
+
first_expires_at, first_conn = connections.first
|
40
|
+
return if (first_expires_at.nil? || fresh?(first_expires_at)) && !closed?(first_conn)
|
41
41
|
|
42
42
|
connections.synchronize do
|
43
|
-
fresh, stale = connections.partition do |expires_at,
|
44
|
-
fresh?(expires_at)
|
43
|
+
fresh, stale = connections.partition do |expires_at, conn|
|
44
|
+
fresh?(expires_at) && !closed?(conn)
|
45
45
|
end
|
46
46
|
connections.replace(fresh)
|
47
47
|
stale.each { |_, conn| closer.call(conn) }
|
@@ -71,6 +71,13 @@ class SSHKit::Backend::ConnectionPool::Cache
|
|
71
71
|
end
|
72
72
|
|
73
73
|
def closed?(conn)
|
74
|
-
conn.respond_to?(:closed?) && conn.closed?
|
74
|
+
return true if conn.respond_to?(:closed?) && conn.closed?
|
75
|
+
# test if connection is alive
|
76
|
+
conn.process(0) if conn.respond_to?(:process)
|
77
|
+
return false
|
78
|
+
rescue IOError => e
|
79
|
+
# connection is closed by server
|
80
|
+
return true if e.message == 'closed stream'
|
81
|
+
raise
|
75
82
|
end
|
76
83
|
end
|
data/lib/sshkit/version.rb
CHANGED
@@ -180,7 +180,7 @@ module SSHKit
|
|
180
180
|
size = 25
|
181
181
|
fills = SecureRandom.random_bytes(1024*1024)
|
182
182
|
file_name = "/tmp/file-#{size}.txt"
|
183
|
-
File.open(file_name, '
|
183
|
+
File.open(file_name, 'wb') do |f|
|
184
184
|
(size).times {f.write(fills) }
|
185
185
|
end
|
186
186
|
file_contents = ""
|
@@ -188,7 +188,7 @@ module SSHKit
|
|
188
188
|
upload!(file_name, file_name)
|
189
189
|
file_contents = download!(file_name)
|
190
190
|
end.run
|
191
|
-
assert_equal File.open(file_name).read, file_contents
|
191
|
+
assert_equal File.open(file_name, 'rb').read, file_contents
|
192
192
|
end
|
193
193
|
|
194
194
|
def test_upload_via_pathname
|
@@ -212,6 +212,20 @@ module SSHKit
|
|
212
212
|
end.run
|
213
213
|
assert_equal("Enter Data\nCaptured SOME DATA", captured_command_result)
|
214
214
|
end
|
215
|
+
|
216
|
+
def test_connection_pool_keepalive
|
217
|
+
# ensure we enable connection pool
|
218
|
+
SSHKit::Backend::Netssh.pool.idle_timeout = 10
|
219
|
+
Netssh.new(a_host) do |_host|
|
220
|
+
test :false
|
221
|
+
end.run
|
222
|
+
sleep 2.5
|
223
|
+
captured_command_result = nil
|
224
|
+
Netssh.new(a_host) do |_host|
|
225
|
+
captured_command_result = capture(:echo, 'some_value')
|
226
|
+
end.run
|
227
|
+
assert_equal "some_value", captured_command_result
|
228
|
+
end
|
215
229
|
end
|
216
230
|
|
217
231
|
end
|
metadata
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sshkit
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.21.
|
4
|
+
version: 1.21.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Lee Hambley
|
8
8
|
- Tom Clements
|
9
|
-
autorequire:
|
9
|
+
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2022-09-05 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: net-ssh
|
@@ -180,6 +180,7 @@ executables: []
|
|
180
180
|
extensions: []
|
181
181
|
extra_rdoc_files: []
|
182
182
|
files:
|
183
|
+
- ".github/dependabot.yml"
|
183
184
|
- ".github/release-drafter.yml"
|
184
185
|
- ".github/workflows/push.yml"
|
185
186
|
- ".gitignore"
|
@@ -275,7 +276,7 @@ licenses:
|
|
275
276
|
- MIT
|
276
277
|
metadata:
|
277
278
|
changelog_uri: https://github.com/capistrano/sshkit/releases
|
278
|
-
post_install_message:
|
279
|
+
post_install_message:
|
279
280
|
rdoc_options: []
|
280
281
|
require_paths:
|
281
282
|
- lib
|
@@ -290,8 +291,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
290
291
|
- !ruby/object:Gem::Version
|
291
292
|
version: '0'
|
292
293
|
requirements: []
|
293
|
-
rubygems_version: 3.
|
294
|
-
signing_key:
|
294
|
+
rubygems_version: 3.3.21
|
295
|
+
signing_key:
|
295
296
|
specification_version: 4
|
296
297
|
summary: SSHKit makes it easy to write structured, testable SSH commands in Ruby
|
297
298
|
test_files:
|