I need to run a Python script which will get the password from the user and login into the specific box using SSH.
password = getpass.getpass('password:')
...
...
command='ssh' + ' ' + "IPname"
p = subprocess.Popen(command,shell=True,stdout=PIPE).communicate(password)[0]
But the above script is not working and still it is looking for password.
pyexpectto send the password when the process expects it. You could also just avoid using passwords and usepublic key authentification.