rosh 0.9.7 → 0.9.8

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e3c244fe02aac976b4bc470e13f529e71bd0a0ec43cc2a389222b7dd7b9b2fc2
4
- data.tar.gz: e4283b6e8c61adb188861184350959de02ba1c75ecc751bf1c8101c4f6934f31
3
+ metadata.gz: 5e3423833dad99eaf3db27ca753520ab865385a1dff3326f3dffd612297cccb7
4
+ data.tar.gz: cb28364217707106482da121b7842f5f4d6894c501330e10861e6c89a3062e35
5
5
  SHA512:
6
- metadata.gz: 12de5a2533f7943d5adc5f29d5f675f97da16e692c615eb40e0357adbce3c649619d44536fd92f5278cb7157a798c32658207869875865b7bdf42ebf14536fcd
7
- data.tar.gz: cb3c1055ad0e11fd5ad55c81268508ed795d165157606e0c16925fc3dd18e3ba0fb74c39b5104926766accf9b6d619e5e62f73561a83bc5336377fdbe1423ed7
6
+ metadata.gz: 201f582429c6e1b15bf5516db2abc236e6977d117b579faae4fdb2f243b965979a3cf6be69e19c0df19a72b705c541c45e87bc11430f04633a3725769040951f
7
+ data.tar.gz: e2fdf6bfb3d9861e72a47bbda8fa5a5b94e3747fa0e77a30f5678c6ad484f06257ff5aaaa839b8c2fccc5772326f3f5b1469acd3cfb0f14779cdbdeff021345e
data/README.md CHANGED
@@ -31,6 +31,9 @@ Or install it yourself as:
31
31
  If ~/.ssh/config contains LocalForward or RemoteForward for the host, the same
32
32
  forwarding options are passed to `ssh` automatically.
33
33
 
34
+ If the host uses `ProxyJump` or `ProxyCommand`, rosh also carries that proxy
35
+ setting over to the spawned `ssh` command.
36
+
34
37
  If a `LocalForward` is skipped because the local port is actually in use,
35
38
  rosh retries that forwarding on later reconnect attempts instead of dropping it
36
39
  for the rest of the process lifetime.
data/lib/rosh/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  class Rosh
2
- VERSION = '0.9.7'
2
+ VERSION = '0.9.8'
3
3
  end
data/lib/rosh.rb CHANGED
@@ -2,6 +2,7 @@ require 'uri'
2
2
  require 'resolv'
3
3
  require 'net/ssh/config'
4
4
  require 'optparse'
5
+ require 'shellwords'
5
6
  require 'socket'
6
7
  require File.join(File.dirname(__FILE__), %w[rosh version])
7
8
 
@@ -42,7 +43,9 @@ class Rosh
42
43
  @host = config[:host_name] if config[:host_name]
43
44
  @base_ssh_opts << "-l #{config[:user]}" if config[:user]
44
45
  @base_ssh_opts << "-p #{config[:port]}" if config[:port]
45
- @base_ssh_opts << "-J #{config[:proxy].jump_proxies}" if config[:proxy]
46
+ if proxy_option = ssh_proxy_option(config[:proxy])
47
+ @base_ssh_opts << proxy_option
48
+ end
46
49
  if keys = config[:keys]
47
50
  keys.each{|k| @base_ssh_opts << "-i #{k}"}
48
51
  end
@@ -102,6 +105,16 @@ class Rosh
102
105
  end
103
106
 
104
107
  private
108
+ def ssh_proxy_option(proxy)
109
+ return nil unless proxy
110
+
111
+ if proxy.respond_to?(:jump_proxies)
112
+ "-J #{proxy.jump_proxies}"
113
+ elsif proxy.respond_to?(:command_line_template)
114
+ "-o ProxyCommand=#{Shellwords.escape(proxy.command_line_template)}"
115
+ end
116
+ end
117
+
105
118
  def refresh_ssh_opts!
106
119
  @ssh_opts = @base_ssh_opts.dup
107
120
  @local_forward_specs.each do |spec|
@@ -1,6 +1,7 @@
1
1
  require 'minitest/autorun'
2
2
  require 'tmpdir'
3
3
  require 'fileutils'
4
+ require 'shellwords'
4
5
 
5
6
  require_relative '../lib/rosh'
6
7
 
@@ -30,6 +31,14 @@ class RoshForwardingTest < Minitest::Test
30
31
  Host grav
31
32
  LocalForward 127.0.0.1 3131 localhost 3131
32
33
  RemoteForward 8082 localhost 8082
34
+
35
+ Host grav-jump
36
+ HostName grav.example.com
37
+ ProxyJump bastion.example.com
38
+
39
+ Host grav-command
40
+ HostName grav.example.com
41
+ ProxyCommand ssh bastion.example.com -W %h:%p
33
42
  CONFIG
34
43
  ENV['HOME'] = @tmp_home
35
44
  end
@@ -63,6 +72,21 @@ class RoshForwardingTest < Minitest::Test
63
72
  assert_includes ssh_opts, '-R 8082:localhost:8082'
64
73
  end
65
74
 
75
+ def test_ssh_opts_include_proxy_jump_from_ssh_config
76
+ rosh = Rosh.new('grav-jump')
77
+ ssh_opts = rosh.instance_variable_get(:@ssh_opts)
78
+
79
+ assert_includes ssh_opts, '-J bastion.example.com'
80
+ end
81
+
82
+ def test_ssh_opts_include_proxy_command_from_ssh_config
83
+ rosh = Rosh.new('grav-command')
84
+ ssh_opts = rosh.instance_variable_get(:@ssh_opts)
85
+
86
+ expected = "-o ProxyCommand=#{Shellwords.escape('ssh bastion.example.com -W %h:%p')}"
87
+ assert_includes ssh_opts, expected
88
+ end
89
+
66
90
  def test_forwarding_is_skipped_when_local_port_is_in_use
67
91
  klass = Class.new(Rosh) do
68
92
  def local_forward_available?(_spec)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rosh
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.7
4
+ version: 0.9.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Genki Takiuchi
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2026-04-03 00:00:00.000000000 Z
11
+ date: 2026-04-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: net-ssh