Thursday, April 25, 2019

Paramiko double SSH

I'm writing a python script that goes through our various networks and logs their information. I've been using paramiko so far and haven't had any trouble ssh'ing into most of our networks, but there's one network that has been a pain (network B). It hangs directly off of network A, so you can only SSH into B after SSH'ing into A. Pinging B is simple enough doing something like:

ssh.connect('aa.aaa.aa.aa', port=22, username='usr', password='pass')

stdin, stdout, stderr = ssh.exec_command("ping bb.bbb.bb.bb")

but doing a straight

ssh.connect('bb.bbb.bb.bb', port=22, username='usr', password='pass') to get into B doesn't work and after doing something like...

stdin, stdout, stderr = ssh.exec_command("ssh [usr@bb.bbb.bb.bb](mailto:usr@bb.bbb.bb.bb)")

requires me to later enter the password. I've been trying to find sources, like the client API http://docs.paramiko.org/en/2.4/api/client.html , but so far have been a bit stuck. Any help would be greatly appreciated. Thank you!



No comments:

Post a Comment