sshpass -P mysshpass ssh root@127.0.0.1 "./myscript.py"
Above is the command that I execute from shell, it asks me for a password as "myscript.py" is scripted to ask for it. But when I execute the same command from python, it doesn't prompt me for password. 
my python code
os.system(sshpass -P mysshpass ssh root@127.0.0.1 "./myscript.py")
you might consider paramiko module, or by specifiying a key file (rsa private key) with ssh -i (see authorized_keys if you are not familiar with ssh auth
How to provide a password over ssh using python script?