Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import os
- import sys
- import time
- import paramiko
- import subprocess
- message="Use 1 to copy script from server and start an atom instance on it or 2 to upload it on the server.\n"
- print message
- ssh = paramiko.SSHClient()
- ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
- user="target"
- password="qwertyuiop12345689010"
- host="45.79.206.221"
- port=22
- if len(sys.argv) < 2:
- print "You need to give me a file first! Run python "+sys.argv[0]+" <filename>"
- sys.exit()
- else:
- thefile=sys.argv[1]
- c=raw_input("Choose 1 or 2: ")
- if int(c) == 1:
- ssh.connect(host, port=port, username=user, password=password, timeout=3)
- stdin, stdout, stderr = ssh.exec_command("curl --upload-file ./"+thefile+" https://transfer.sh/"+thefile)
- link = stdout.read()
- print "We git link! - %r \n" % link
- print "Downloading..."
- time.sleep(0.5)
- os.system("wget %r"%link)
- time.sleep(0.2)
- os.system("atom "+thefile)
- sys.exit(0)
- elif int(c) == 2:
- proc = subprocess.Popen(["curl --upload-file ./"+thefile+" https://transfer.sh/"+thefile], stdout=subprocess.PIPE, shell=True)
- (out, err) = proc.communicate()
- print out
- ssh.connect(host, port=port, username=user, password=password, timeout=3)
- time.sleep(2)
- ssh.exec_command("rm "+thefile)
- ssh.exec_command("cd art/")
- ssh.exec_command("wget %r" % out)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement