Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Start interactive SSH session from Python script

Tags:

python

ssh

I'd like to start an interactive SSH terminal from a Python script without using modules like pexpect or paramiko - I want to stick with what CentOS pre-installed Python provides me (to ease compatibility and deployment issues).

I can run commands fine using the subprocess module, but cannot get an interactive terminal. In Perl, I would just use backticks to achieve this, but am looking for the pythonic way of doing this.

Can someone point me in the right direction?

UPDATE - based on @leoluk's answer, I used the instructions from docs.python.org to come up with: subprocess.call("ssh ...", shell=True)

like image 334
sholsapp Avatar asked Sep 11 '10 19:09

sholsapp


1 Answers

I get an interactive terminal if I use os.system('ssh [...]')

like image 105
leoluk Avatar answered Sep 25 '22 16:09

leoluk