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()
评论列表
文章目录