Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python script - connect to SSH and run command

I already know there are ssh modules for Python, that's not for what I'm looking for. What I want to have is an python script to do the following:

  1. > connect to an [ input by user ] SSH host
  2. > connect using the credentials [ provided by the user ]
  3. > run command on the SSH host [ telnet to [host - input by user ]
  4. > Select menu item in the telnet session

Thanks in advance,

Best regards,

like image 757
Ilias Avatar asked Feb 04 '11 10:02

Ilias


4 Answers

Use paramiko, see http://jessenoller.com/2009/02/05/ssh-programming-with-paramiko-completely-different/ for a through example of using it.

like image 192
ismail Avatar answered Nov 15 '22 21:11

ismail


Use paramiko or the libssh2 python bindings.

like image 36
ThiefMaster Avatar answered Nov 15 '22 20:11

ThiefMaster


now the popular solution is Fabric

like image 30
linbo Avatar answered Nov 15 '22 20:11

linbo


If you're actually looking for a module that lets you automate CLI interaction, there's pexpect

like image 37
Vlad H Avatar answered Nov 15 '22 19:11

Vlad H