I am writing a program to ssh into another computer on our network. However with the commands ssh, scp etc... terminal requests the password and os.system() seems to open a new terminal window each time it is called. This makes it difficult to enter the password.

I have been looking at os.system(), popen() and appscript's app(u'/Applications/Utilities/Terminal').do_script().

Any help would be greatly appreciated.

9 Years
Discussion Span
Last Post by BearofNH

Remotely connecting to other systems by invoking external bash commands is cumbersome, isn't it? You'd be better served by learning how to use the paramiko package, which lets you do the same thing but from within Python:


Check out the instructions that come with the package for short demos on how to connect to remote systems. I use it at work, and it wasn't too much hassle to set up and use.

There are ways of doing this with os.popen(), if you're dead set on doing things that way - you can use "here documents" to enter the password and commands, I believe - but I haven't actually tried that on my own, so don't hold me to it.

Hope that helps.


I've successfully used telnetlib (included in Python, I believe) in similar cases. Telnet is a more primitive remote-terminal protocol which suffers from a number of security issues, one reason why SSH was developed. If you can use paramiko then by all means do so. But if you run into problems with it, consider telnetlib. In my case security is not an issue due to physical isolation.

This article has been dead for over six months. Start a new discussion instead.
Be sure to adhere to our posting rules.