SHARE
TWEET

Untitled

a guest Sep 11th, 2019 98 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import os
  2. import paramiko
  3.  
  4. config_file = os.path.join(os.getenv('HOME'), '.ssh/config')
  5. ssh_config = paramiko.SSHConfig()
  6. ssh_config.parse(open(config_file, 'r'))
  7. lkup = ssh_config.lookup('dev-env')
  8.  
  9. ssh = paramiko.SSHClient()
  10. ssh.load_system_host_keys()
  11. ssh.connect(
  12.     lkup['hostname'],
  13.     username=lkup['user'],
  14.     key_filename=lkup['identityfile'],
  15.     sock=paramiko.ProxyCommand(lkup['proxycommand'])
  16. )
  17.  
  18. sftp = ssh.open_sftp()        
  19. print(sftp.listdir('/var/log'))
  20. sftp.close()
  21. ssh.close()
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
 
Top