Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.ruby > #5115 > unrolled thread
| Started by | Josh Hurtado <djotter@mac.com> |
|---|---|
| First post | 2011-05-26 18:20 -0500 |
| Last post | 2011-05-26 19:02 -0500 |
| Articles | 2 — 2 participants |
Back to article view | Back to comp.lang.ruby
Jump box ideas Josh Hurtado <djotter@mac.com> - 2011-05-26 18:20 -0500
Re: Jump box ideas John W Higgins <wishdev@gmail.com> - 2011-05-26 19:02 -0500
| From | Josh Hurtado <djotter@mac.com> |
|---|---|
| Date | 2011-05-26 18:20 -0500 |
| Subject | Jump box ideas |
| Message-ID | <9b0b06759f3206bf2f3ba3260374aa33@ruby-forum.com> |
Hi Everyone, I posted a differnt but related thread about this so though I would hit from a differnt direction. I have a secure SSH box which has access to my differnt Cisco routers. I want to write a program that a) ssh's from my machine to the jump box b) run through a list of routers and telnet into each one and grab the running config c) close the session Trying to fiugre out a good way to approach this. I can get the NET::SSH session open to the box, but can't figure out how to go form there to step 2. -- Posted via http://www.ruby-forum.com/.
[toc] | [next] | [standalone]
| From | John W Higgins <wishdev@gmail.com> |
|---|---|
| Date | 2011-05-26 19:02 -0500 |
| Message-ID | <BANLkTimntdehLk1bJKy8Y6zcxCRag3YROQ@mail.gmail.com> |
| In reply to | #5115 |
[Note: parts of this message were removed to make it a legal post.]
Afternoon Josh,
On Thu, May 26, 2011 at 4:20 PM, Josh Hurtado <djotter@mac.com> wrote:
> Hi Everyone,
> I posted a differnt but related thread about this so though I would hit
> from a differnt direction.
>
> I have a secure SSH box which has access to my differnt Cisco routers. I
> want to write a program that
>
> a) ssh's from my machine to the jump box
> b) run through a list of routers and telnet into each one and grab the
> running config
> c) close the session
>
> Trying to fiugre out a good way to approach this. I can get the NET::SSH
> session open to the box, but can't figure out how to go form there to
> step 2.
>
You want to use SSH Fowarding to forward your telnet sessions over the wire
to the remote side.
http://net-ssh.rubyforge.org/ssh/v2/api/ <- the ssh api documentation has
forwarding as the third to last line of the large example at the top of the
page.
Basically you do the following - you tell the ssh session to forward a LOCAL
port over the wire to a remote address (in this case one of your cisco
servers).
So as an example
If you had a server at 10.0.0.1 port 21 then you could write
ssh.forward.local(12345, "10.0.0.1", 21)
Then use the telnet object to connect to port 12345 - this will
automatically be forwarded over the wire to 10.0.0.1 port 21 via the ssh
connection.
So for step 2 you would create an array of your router addresses and then
something like this
addrs = ['10.0.0.1', '10.0.0.2', '10.0.0.3']
addrs.each { |addr|
ssh.forward.local(12345, addr, 21)
connect to port 12345 on your localhost with telnet and pull down the
config
}
John
John
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.ruby
csiph-web