コード例 #1
0
def download_files_to_minion(host, usr, pwd):
    ssh = paramiko.SSHClient()
    try:
        ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
        ssh.connect(host, username=usr, password=pwd)
        scp = SCPClient(ssh.get_transport(), progress=progress)

        scp.put(os.path.join(_OP_FOLDER_PATH, 'MACsec_minion_dependencies'),
                recursive=True,
                remote_path="/var/db/scripts/commit")
        scp.put(os.path.join(_OP_FOLDER_PATH, 'local_minion.py'),
                remote_path="/var/db/scripts/commit")
        scp.put(os.path.join(_OP_FOLDER_PATH, 'minion_environment.yaml'),
                remote_path="/var/db/scripts/commit")
        scp.put(os.path.join(_OP_FOLDER_PATH, 'delete_MACsec_interface.py'),
                remote_path="/var/db/scripts/op")

        ssh.close()
    except Exception as err:
        print(err)
        return
    else:
        ssh.close()
コード例 #2
0
ファイル: scphash.py プロジェクト: liwonace/lsiem
    sys.argv[1]
except IndexError:
    print(
        "usage: python scphash.py [hostname] [username] [password] [filename] [hash algorism]"
    )
    print("[[hash algorism number]] 1: MD5, 2: SHA-1, 3: SHA-256, 4: SHA-512")
    sys.exit(1)

ssh = SSHClient()
ssh.load_system_host_keys()
# ssh.connect('192.168.7.71',username='******',password='******')
# print(sys.argv[1], type(sys.argv[1]))
ssh.connect(sys.argv[1], username=sys.argv[2], password=sys.argv[3])

# SCPCLient takes a paramiko transport as an argument
scp = SCPClient(ssh.get_transport())

# Uploading the 'test' directory with its content in the
# '/home/user/dump' remote directory
scp.put(sys.argv[4], recursive=True, remote_path='/home/lsiem/')

# send hash value file
BLOCKSIZE = 65536

if sys.argv[5] == '1':
    hasher = hashlib.md5()
elif sys.argv[5] == '2':
    hasher = hashlib.sha1()
elif sys.argv[5] == '3':
    hasher = hashlib.sha256()
elif sys.argv[5] == '4':
コード例 #3
0
ファイル: collect_logs.py プロジェクト: markfink/supercars
def collect_file(ssh, archive, targetdir):
    '''get a file from remote'''
    scp = SCPClient(ssh.get_transport())
    scp.get(archive, targetdir)
コード例 #4
0
ファイル: start_counters.py プロジェクト: markfink/supercars
def upload(ssh, script, targetdir):
    """upload a file to remote"""
    scp = SCPClient(ssh.get_transport())
    scp.put(script, targetdir)
コード例 #5
0
def download_files_to_master(host, usr, pwd):
    if host == 'localhost':
        print(
            'copying MACsec_master_dependencies to /var/db/scripts/jet/MACsec_master_dependencies...'
        )
        cpdir(os.path.join(_OP_FOLDER_PATH, 'MACsec_master_dependencies'),
              '/var/db/scripts/jet/MACsec_master_dependencies')
        print('copying remote_master.py to /var/db/scripts/jet/...')
        copyfile(os.path.join(_OP_FOLDER_PATH, 'remote_master.py'),
                 '/var/db/scripts/jet/remote_master.py')
        print('copying master_environment.yaml to /var/db/scripts/jet/...')
        copyfile(os.path.join(_OP_FOLDER_PATH, 'master_environment.yaml'),
                 '/var/db/scripts/jet/master_environment.yaml')

        print(
            'copying MACsec_minion_dependencies to /var/db/scripts/commit/...')
        cpdir(os.path.join(_OP_FOLDER_PATH, 'MACsec_minion_dependencies'),
              '/var/db/scripts/commit/MACsec_minion_dependencies')
        print('copying local_minion.py to /var/db/scripts/commit/...')
        copyfile(os.path.join(_OP_FOLDER_PATH, 'local_minion.py'),
                 '/var/db/scripts/commit/local_minion.py')
        print('minion_environment.yaml to /var/db/scripts/commit/...')
        copyfile(os.path.join(_OP_FOLDER_PATH, 'minion_environment.yaml'),
                 '/var/db/scripts/commit/minion_environment.yaml')
    else:
        ssh = paramiko.SSHClient()
        try:
            ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
            ssh.connect(host, username=usr, password=pwd)
            scp = SCPClient(ssh.get_transport(), progress=progress)

            scp.put(os.path.join(_OP_FOLDER_PATH,
                                 'MACsec_master_dependencies'),
                    recursive=True,
                    remote_path="/var/db/scripts/op")
            scp.put(os.path.join(_OP_FOLDER_PATH,
                                 'MACsec_master_dependencies'),
                    recursive=True,
                    remote_path="/var/db/scripts/jet")

            scp.put(os.path.join(_OP_FOLDER_PATH, 'remote_master.py'),
                    remote_path="/var/db/scripts/op")
            scp.put(os.path.join(_OP_FOLDER_PATH, 'remote_master.py'),
                    remote_path="/var/db/scripts/jet")
            scp.put(os.path.join(_OP_FOLDER_PATH, 'master_environment.yaml'),
                    remote_path="/var/db/scripts/op")
            scp.put(os.path.join(_OP_FOLDER_PATH, 'master_environment.yaml'),
                    remote_path="/var/db/scripts/jet")

            scp.put(os.path.join(_OP_FOLDER_PATH,
                                 'MACsec_minion_dependencies'),
                    recursive=True,
                    remote_path="/var/db/scripts/commit")

            scp.put(os.path.join(_OP_FOLDER_PATH, 'local_minion.py'),
                    remote_path="/var/db/scripts/commit")
            scp.put(os.path.join(_OP_FOLDER_PATH, 'minion_environment.yaml'),
                    remote_path="/var/db/scripts/commit")
            scp.put(os.path.join(_OP_FOLDER_PATH,
                                 'delete_MACsec_interface.py'),
                    remote_path="/var/db/scripts/op")

            ssh.close()
        except Exception as err:
            print(err)
            return
        else:
            ssh.close()