Created
July 15, 2013 14:41
-
-
Save draftcode/6000484 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| require 'net/ssh' | |
| require 'tmpdir' | |
| require 'socket' | |
| path = Dir::Tmpname::create('forwarded_socket') { |path| path } | |
| UNIXServer.open(path) do |server| | |
| at_exit do | |
| File.unlink(path) | |
| end | |
| Net::SSH.start('10.0.1.201', 'draftcode') do |ssh| | |
| ssh.forward.local(server, '127.0.0.1', 1234) | |
| Thread.fork { ssh.loop { true } } | |
| loop do | |
| p ssh.forward.active_locals | |
| sleep 1 | |
| end | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment