本文整理汇总了Python中paramiko.config.SSH_PORT属性的典型用法代码示例。如果您正苦于以下问题:Python config.SSH_PORT属性的具体用法?Python config.SSH_PORT怎么用?Python config.SSH_PORT使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类paramiko.config
的用法示例。
在下文中一共展示了config.SSH_PORT属性的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _connect
# 需要导入模块: from paramiko import config [as 别名]
# 或者: from paramiko.config import SSH_PORT [as 别名]
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()
示例2: connect
# 需要导入模块: from paramiko import config [as 别名]
# 或者: from paramiko.config import SSH_PORT [as 别名]
def connect(
self,
hostname,
port=SSH_PORT,
username=None,
password=None,
pkey=None,
key_filename=None,
timeout=None,
allow_agent=True,
look_for_keys=True,
compress=False,
sock=None,
gss_auth=False,
gss_kex=False,
gss_deleg_creds=True,
gss_host=None,
banner_timeout=None):
options = self.config.lookup(hostname)
identity_file = options.get('identityfile', [key_filename])
if identity_file:
identity_file = identity_file[0]
if identity_file and not identity_file.startswith('/'):
identity_file = join(self.config_directory, identity_file)
port = int(options.get('port', port))
super().connect(
hostname=options.get('hostname', hostname),
port=port,
username=options.get('user', username),
password=options.get('password', password),
pkey=pkey,
key_filename=identity_file,
timeout=options.get('connecttimeout', timeout),
allow_agent=allow_agent,
look_for_keys=look_for_keys,
compress=compress,
sock=sock,
gss_auth=gss_auth,
gss_kex=gss_kex,
gss_deleg_creds=gss_deleg_creds,
gss_host=gss_host,
banner_timeout=banner_timeout
)
self._sftp_client = self.open_sftp()