pry-remote-ssh 1.0.0
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 +7 -0
- data/lib/pry-remote/ssh.rb +97 -0
- metadata +87 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: be15c99096d7fbbfb8185989ba383fbc537baf3a7145ea657fe90390c47fab3a
|
4
|
+
data.tar.gz: 45687fc70a7bea26792deebd4e8ac7153d7237160df24fcc99723a77c4c191cc
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 802b64c777560ee6df5ffdecd68e9f0ae9be3318466dde144354aa0a8b1141a11825a034b244b826f37eb5f1328c052d060dcdfaf80e32ea65d72104145b474f
|
7
|
+
data.tar.gz: a668c26048c833b7862d43f264adc4541b997cb91d88dc79f33a500ae21424335030258319ea0fd05a80c5b48aaa2eb679f536ddadc318255775d3066c1c4de7
|
@@ -0,0 +1,97 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'pry-remote'
|
4
|
+
require 'net/ssh'
|
5
|
+
|
6
|
+
module PryRemote
|
7
|
+
module SSH
|
8
|
+
VERSION = '1.0.0'
|
9
|
+
|
10
|
+
##
|
11
|
+
# Pry remote session forwarding over SSH.
|
12
|
+
class Server
|
13
|
+
##
|
14
|
+
# Initialize the services and run the Pry remote session and SSH tunnel.
|
15
|
+
#
|
16
|
+
# PryRemote::SSH::Server.run('remote_host', object, options)
|
17
|
+
def self.run(*args)
|
18
|
+
new(*args).run
|
19
|
+
end
|
20
|
+
|
21
|
+
##
|
22
|
+
# Initialize the services.
|
23
|
+
#
|
24
|
+
# The only required argument is +remote_host+. By default, the +object+
|
25
|
+
# to run the Pry remote session on is set to `nil`. The optional argument
|
26
|
+
# +options+ hash can be used to set the +remote_user+, +local_port+, and
|
27
|
+
# +remote_port+ for the SSH tunnel, as well as the +ssh_options+ and the
|
28
|
+
# +pry_options+ for the Pry remote session.
|
29
|
+
#
|
30
|
+
# PryRemote::SSH::Server.new('remote_host', object, options)
|
31
|
+
def initialize(remote_host, object = nil, options = {})
|
32
|
+
@remote_host = remote_host
|
33
|
+
@object = object
|
34
|
+
|
35
|
+
@remote_user = options[:remote_user] || nil
|
36
|
+
@local_port = options[:local_port] || PryRemote::DefaultPort
|
37
|
+
@remote_port = options[:remote_port] || PryRemote::DefaultPort
|
38
|
+
@ssh_options = options[:ssh_options] || {}
|
39
|
+
@pry_options = options[:pry_options] || {}
|
40
|
+
end
|
41
|
+
|
42
|
+
##
|
43
|
+
# Run the Pry remote session and SSH tunnel.
|
44
|
+
#
|
45
|
+
# The tunnel is teared down when the Pry remote session is closed.
|
46
|
+
def run
|
47
|
+
pry_remote = run_pry_remote
|
48
|
+
ssh = setup_ssh_tunnel
|
49
|
+
|
50
|
+
run_ssh_tunnel(ssh, pry_remote)
|
51
|
+
end
|
52
|
+
|
53
|
+
private
|
54
|
+
|
55
|
+
def run_pry_remote
|
56
|
+
Thread.new do
|
57
|
+
PryRemote::Server.run(@object, 'localhost', @local_port, @pry_options)
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
def run_ssh_tunnel(ssh, pry_remote)
|
62
|
+
loop do
|
63
|
+
break unless pry_remote.alive?
|
64
|
+
|
65
|
+
ssh.loop(1)
|
66
|
+
end
|
67
|
+
ensure
|
68
|
+
ssh.close
|
69
|
+
puts '[pry-remote] SSH Connection closed'
|
70
|
+
end
|
71
|
+
|
72
|
+
def setup_ssh_tunnel
|
73
|
+
ssh = Net::SSH.start(@remote_host, @remote_user, @ssh_options)
|
74
|
+
puts "[pry-remote] SSH Connection to #{@remote_host} established"
|
75
|
+
|
76
|
+
ssh.forward.remote(@local_port, 'localhost', @remote_port)
|
77
|
+
puts "[pry-remote] Forwarding port #{@local_port} to #{@remote_port}"
|
78
|
+
|
79
|
+
ssh
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
##
|
86
|
+
# Pry remote session forwarding over SSH.
|
87
|
+
class Object
|
88
|
+
##
|
89
|
+
# Start a Pry remote session over SSH via object binding.
|
90
|
+
#
|
91
|
+
# binding.remote_pry_ssh('remote_host')
|
92
|
+
def remote_pry_ssh(remote_host, options = {})
|
93
|
+
PryRemote::SSH::Server.run(remote_host, self, options)
|
94
|
+
end
|
95
|
+
|
96
|
+
alias pry_remote_ssh remote_pry_ssh
|
97
|
+
end
|
metadata
ADDED
@@ -0,0 +1,87 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: pry-remote-ssh
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Tobias Schäfer
|
8
|
+
bindir: bin
|
9
|
+
cert_chain: []
|
10
|
+
date: 2025-03-21 00:00:00.000000000 Z
|
11
|
+
dependencies:
|
12
|
+
- !ruby/object:Gem::Dependency
|
13
|
+
name: net-ssh
|
14
|
+
requirement: !ruby/object:Gem::Requirement
|
15
|
+
requirements:
|
16
|
+
- - ">="
|
17
|
+
- !ruby/object:Gem::Version
|
18
|
+
version: '7.2'
|
19
|
+
- - "<"
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '7.4'
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
requirements:
|
26
|
+
- - ">="
|
27
|
+
- !ruby/object:Gem::Version
|
28
|
+
version: '7.2'
|
29
|
+
- - "<"
|
30
|
+
- !ruby/object:Gem::Version
|
31
|
+
version: '7.4'
|
32
|
+
- !ruby/object:Gem::Dependency
|
33
|
+
name: pry-remote
|
34
|
+
requirement: !ruby/object:Gem::Requirement
|
35
|
+
requirements:
|
36
|
+
- - ">="
|
37
|
+
- !ruby/object:Gem::Version
|
38
|
+
version: '0.1'
|
39
|
+
- - "<"
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
version: '0.3'
|
42
|
+
type: :runtime
|
43
|
+
prerelease: false
|
44
|
+
version_requirements: !ruby/object:Gem::Requirement
|
45
|
+
requirements:
|
46
|
+
- - ">="
|
47
|
+
- !ruby/object:Gem::Version
|
48
|
+
version: '0.1'
|
49
|
+
- - "<"
|
50
|
+
- !ruby/object:Gem::Version
|
51
|
+
version: '0.3'
|
52
|
+
description: 'Connect to Pry remotely via SSH forwarding
|
53
|
+
|
54
|
+
'
|
55
|
+
email:
|
56
|
+
- github@blackox.org
|
57
|
+
executables: []
|
58
|
+
extensions: []
|
59
|
+
extra_rdoc_files: []
|
60
|
+
files:
|
61
|
+
- lib/pry-remote/ssh.rb
|
62
|
+
homepage: https://github.com/tschaefer/pry-remote-ssh
|
63
|
+
licenses:
|
64
|
+
- MIT
|
65
|
+
metadata:
|
66
|
+
rubygems_mfa_required: 'true'
|
67
|
+
source_code_uri: https://github.com/tschaefer/pry-remote-ssh
|
68
|
+
bug_tracker_uri: https://github.com/tschaefer/pry-remote-ssh/issues
|
69
|
+
post_install_message: All your Pry connection are belong to us!
|
70
|
+
rdoc_options: []
|
71
|
+
require_paths:
|
72
|
+
- lib
|
73
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
74
|
+
requirements:
|
75
|
+
- - ">="
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '3.1'
|
78
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
requirements: []
|
84
|
+
rubygems_version: 3.6.6
|
85
|
+
specification_version: 4
|
86
|
+
summary: Connect to Pry remotely via SSH forwarding
|
87
|
+
test_files: []
|