sftp.py 文件源码

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

项目:hashedbackup 作者: wojas 项目源码 文件源码
def _connect(self):
        if 'proxycommand' in self.config:
            proxy = paramiko.ProxyCommand(self.config['proxycommand'])
            # TODO: check this code, needed?
            #subprocess.check_output(
            #    [os.environ['SHELL'], '-c',
            #        'echo %s' % self.config['proxycommand']]
            #).strip()
        else:
            proxy = None

        # Connect to server
        # Compression will not speedup picture transfers, but will help for
        # the initial remote hash download and for files that are compressible.
        # noinspection PyTypeChecker
        self.client.connect(
            self.config.get('hostname', self.hostname),
            username=self.user or self.config.get('user', None),
            password=self.password,
            port=self.config.get('port', SSH_PORT),
            sock=proxy,
            compress=True)

        transport = self.client.get_transport()
        # https://github.com/paramiko/paramiko/issues/175
        transport.window_size = 2147483647
        # 512MB -> 4GB, this is a security degradation
        transport.packetizer.REKEY_BYTES = pow(2, 32)

        self.sftp = self.client.open_sftp()
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号