I have the following code (updated to include pexpect):
import sys
import subprocess
import pexpect
print \"0\"
ssh = subprocess.Popen(\"ssh -A -t username1@200.
The password prompt isn't written to stdout. You'll need something like pexpect to capture it. This thread has more info: Sending a password over SSH or SCP with subprocess.Popen
Edit: Regarding your updated pexpect code, first of all, if you read the documentation for subprocess, you'll see that communicate() waits for the process to terminate, that's why your program hangs until you kill the ssh session. And your call to pexpect.spawn looks wrong, it expects a string, not a Popen object. You don't need subprocess at all here.