Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.ruby > #6991
| Newsgroups | comp.lang.ruby |
|---|---|
| Date | 2014-06-15 20:15 -0700 |
| Message-ID | <9e889bca-de17-4e15-841e-33d878233344@googlegroups.com> (permalink) |
| Subject | Net::SSH forward local port |
| From | hartj659@gmail.com |
I'm trying to programmatically configure an ssh local port forward through a middle server, then run some commands to a remote ssh server on the far end. I created this ruby script:
Net::SSH.start('middleserver', 'testuser', :password => 'testpwd') do |ssh|
ssh.forward.local(22004, "remoteserver", 22)
ssh.loop
end
After running this script, I ran this on the command line:
ssh remoteuser@localhost -p 22004 "hostname"
Works.
Then I tried this:
Net::SSH.start('middleserver', 'testuser', :password => 'testpwd') do |ssh|
ssh.forward.local(22004, "remoteserver", 22)
ssh.loop
end
Net::SSH.start('localhost', 'remoteuser', :password => 'remotepwd', :port => 22004) do |ssh|
output = ssh.exec!("hostname")
print output
end
This does not work. I guess this is a naive implementation.
Any suggestions on how I should code this so I can forward commands from my localhost port to the remote ssh server?
Thanks for your suggestions.
Back to comp.lang.ruby | Previous | Next | Find similar
Net::SSH forward local port hartj659@gmail.com - 2014-06-15 20:15 -0700
csiph-web