Created
August 3, 2020 17:14
-
-
Save will/d0b7fcc5be61b6cebd649ca39f474886 to your computer and use it in GitHub Desktop.
net::ssh remote port to local socket
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# on remote machine | |
# nc -l -p 1212 | |
# on local machine | |
ssh = Net::SSH.start(remote.ip, "centos", keys_only: true, key_data: [remote.ssh_key]) | |
tempfile = Tempfile.new("net_ssh_forward_test") | |
path = tempfile.path | |
tempfile.delete | |
us = UNIXServer.open(path) | |
ssh.forward.local(us, 'localhost', 1212) | |
client = UNIXSocket.new(us.path) | |
client.puts "hello world" | |
ssh.loop |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment