jamiecaesar / securecrt-tools

SecureCRT scripts, written in Python, for doing various tasks when connected to Cisco equipment.
Apache License 2.0
252 stars 77 forks source link

Dual Jumphost #56

Open cmacasae opened 2 years ago

cmacasae commented 2 years ago

Our environment requires double linux jumphost before we can reach the Cisco devices. Is there anything we can adjust in the script to successfully connect behind double jumphosts?

jamiecaesar commented 2 years ago

Unfortunately I don't think there is a way to handle that in the scripts - at least the multi-device ones. The single device ones you just need to get logged into the device and run the script you want, and it should work.

The multi-device scripts use the built-in feature of SecureCRT to connect through a SOCKS proxy host (They call it "Firewall" in the UI). So unless that feature allows you to chain together "Firewall" references, then it isn't something that the scripts can handle.

That does make me curious though, as I've never tried it. The standard way of dealing with the jump host is to set up a SecureCRT session for the jump box (with auto-login if you don't want to get prompted for each device), and then create a session for your end-device but under the "Firewall" drop-down you select your jump host session that was created first. Then SecureCRT will set up the Socks5 proxy session to whatever you selected under "Firewall" and then proxy the connection to the end device through it.

So I wonder if you can create a session for JumpHost1, then create one for JumpHost2, which references JumpHost1 in the Firewall field, and then finally create you final device session that references JumpHost2 as the firewall. If that doesn't work, then I'm guessing it cannot be done with SecureCRT. I'd love to hear your results, though.

cmacasae commented 2 years ago

This worked. It needed two open securecrt windows.

In the first securecrt window I have two connected sessions which are configured as ssh socks proxy chaining. This is for the two jumphosts.

https://www.vandyke.com/support/tips/socksproxy.html

Then I run m_inventory_report.py in the 2nd securecrt window. It needs to be run from a window with no connected session as the script checks it.

Awesome! Thanks.

cmacasae commented 2 years ago

Update:

Was able to make m_cdp_to_csv working in dual ssh tunnel, by adding ",proxy=proxy)" in line 85 of m_cdp_to_csv.py