Thursday, 7 February 2019

Django Celery task to copy file from remote host using SCP and SSHPASS



@task()
def copyBkpFromJenkinstoDjango():
       ip = ''
       port = ""
       username = ""
       password = ""
       cmd = "sshpass -p '<password>' scp -r root@<remoteIP>:/root/networkBackups /root/Django"
       #print (cmd)
       ssh=paramiko.SSHClient()
       ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
       ssh.connect(ip,port,username,password)
       stdin,stdout,stderr=ssh.exec_command(cmd)
       time.sleep(50)
       outlines=stdout.readlines()
       resp =''.join(outlines)
       #print(resp)
       return resp

No comments:

Post a Comment

Git

1 git add ↳ It lets you add changes from the working directory into the staging area 2 git commit ↳ It lets you save a snapshot of currently...