snmphelpers.py 文件源码

python
阅读 22 收藏 0 点赞 0 评论 0

项目:taf 作者: taf3 项目源码 文件源码
def get_remote_file(hostname, port, username, password, remotepath, localpath):
    """Get remote file to local machine.

    Args:
        hostname(str):  Remote IP-address
        port(int):  Remote SSH port
        username(str):  Remote host username for authentication
        password(str):  Remote host password for authentication
        remotepath(str):  Remote file to download location path
        localpath(str):  Local path to save remote file

    Examples::

        get_remote_file(host, port, username, password, tar_remotepath, tar_localpath)

    """
    transport = paramiko.Transport((hostname, port))
    transport.connect(username=username, password=password)
    sftp = paramiko.SFTPClient.from_transport(transport)
    try:
        sftp.get(remotepath=remotepath, localpath=localpath)
    finally:
        sftp.close()
        transport.close()
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号