a guest Jul 18th, 2019 133 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. from paramiko import SSHClient
  2. import paramiko
  4. client = SSHClient()
  5. client.set_missing_host_key_policy(paramiko.client.AutoAddPolicy)
  6. client.connect('server', username='username', password='password')
  7. #stdin, stdout, stderr = client.exec_command("sudo su - oracle")
  8. stdin, stdout, stderr = client.exec_command('sudo su - oracle', get_pty=True)
  9. stdin.write('passwordn')  # I donno n is compulsory or not. My password don't have it
  10. stdin.flush()
  11. print(
  12. print(
  13. stdin, stdout, stderr = client.exec_command("pwd")
  14. print(
  15. sftp = client.open_sftp()
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand