The following python code hangs on executing cmd2 (works with cmd1). The commands works fine when executed on a shell. I have the same problem with Python 2.3.4 and 2.4 (Windows). I use the latest Cygwin binaries import os cmd1 = "bin\\ssh" cmd2 = "bin\\ssh -i id_dsa admin@myserver.com uptime" def docmd(cmd): print "Doing %s ..." % cmd (stdin, stdouterr) = os.popen4(cmd) for line in stdouterr.readlines(): print line stdin.close() stdouterr.close() print "Done." if __name__ == '__main__': docmd(cmd1) docmd(cmd2) Give me some advice for testing (popen, linux, ...).