Advertisement
Guest User

Untitled

a guest
Jun 29th, 2016
139
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.72 KB | None | 0 0
  1. def ssh_connect(ip,user,pwd):
  2. '''
  3. This function will make an ssh connection to the ip using the credentials passed and return the handler
  4. Args:
  5. ip: IP Address of the box into which ssh has to be done
  6. user: User name of the box to which ssh has to be done
  7. pass: password of the box to which ssh has to be done
  8. Returns:
  9. An ssh handler
  10. '''
  11. ssh = paramiko.SSHClient()
  12. ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
  13. ssh.connect(ip, username=user, password=pwd)
  14. return ssh
  15.  
  16. ssh_obj = ssh_connect(ip, username, password)
  17. folder = "/var/xyz/images/" + build_number
  18. command = "mkdir " + folder
  19. ssh_stdin, ssh_stdout, ssh_stderr = ssh_obj.exec_command(command)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement