What I've tried:
invoke_shell()
thenchannel.send
su
and then sending the password resulted in not being rootinvoke_shell()
and thenchannel.exec_command
resulted in a "Channel Closed" error_transport.open_session()
thenchannel.exec_command
resulted in not being rootinvoke_shell()
then writing to stdin and flushing it resulted in not being root
check this example out:
Example found here with more explanations: http://jessenoller.com/2009/02/05/ssh-programming-with-paramiko-completely-different/
Hope it helps!