How to login the super user(root) in remote host system using pexpect?
user = root user
password = \'pass\'
child = pexpect.spawn(\'ssh %s@%s\'%(user,host,))
i will get answer
child = pexpext.spawn('ssh root@host')
You could also simply log in to a user on ssh like normal, then send commands to log into the root like you normally would in a terminal.
#log into user account
child = pexpect.spawn('ssh clientuser@localhost')
child.expect('Password:')
child.sendline('password')
#then log into root account
child.sendline('su')
child.expect('Password:')
child.sendline('sudopassword1234')
This is just longer and more code, and probably only works on linux the way i wrote it. But you could use this if directly ssh to root doesn't work.