A jump host is a server inside a secure zone, that you access from a less secure zone. You can then jump from this host to greater security zones. An example would be a high security zone inside a corporation.

in this tutorial we are going to get a backup of a router configuration through a jumpserver using JumpSSH JumpSSH is a module for Python 2.7+/3.4+ that can be used to run commands on remote servers through a gateway. installing the required packages

pip install jumpssh 
pip install python-dotenv

we will use python-dotenv to manage our credentials to environment variable.

creating a .env file in the same path of our script

jumpserver_ip = 'your_jump_server_ip' 
jumpserver_username = 'your_jump_server_username' 
jumpserver_password = 'your_jump_server_password' 
remote_ip = 'your_remote_node_ip' 
remote_username = 'your_remote_node_username' 
remote_password = 'your_remote_node_password'

then creating our script

from dotenv import load_dotenv
import jumpssh 
import 

os load_dotenv() 

jumpserver_ip = os.getenv("jumpserver_ip") 
jumpserver_username = os.getenv("jumpserver_username") jumpserver_password = os.getenv("jumpserver_password") 
remote_ip = os.getenv("remote_ip") 
remote_password = os.getenv("remote_password") 

gateway_session = SSHSession(jumpserver_ip, jumpserver_username, password=jumpserver_password).open() 
remote_session = gateway_session.get_remote_session(remote_ip, password=remote_password, allow_agent=False, look_for_keys=False) 

with open('R1.txt', 'w') as fl:
	fl.write(remote_session.get_cmd_output('show running config')) remote_session.close() 


gateway_session.close()