本文整理汇总了Python中paramiko.config.SSHConfig方法的典型用法代码示例。如果您正苦于以下问题:Python config.SSHConfig方法的具体用法?Python config.SSHConfig怎么用?Python config.SSHConfig使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类paramiko.config
的用法示例。
在下文中一共展示了config.SSHConfig方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: parse_ssh_config
# 需要导入模块: from paramiko import config [as 别名]
# 或者: from paramiko.config import SSHConfig [as 别名]
def parse_ssh_config(file_obj):
"""
Provided only as a backward-compatible wrapper around `.SSHConfig`.
"""
config = SSHConfig()
config.parse(file_obj)
return config
示例2: parse_ssh_config
# 需要导入模块: from paramiko import config [as 别名]
# 或者: from paramiko.config import SSHConfig [as 别名]
def parse_ssh_config(file_obj):
"""
Provided only as a backward-compatible wrapper around L{SSHConfig}.
"""
config = SSHConfig()
config.parse(file_obj)
return config
示例3: lookup_ssh_host_config
# 需要导入模块: from paramiko import config [as 别名]
# 或者: from paramiko.config import SSHConfig [as 别名]
def lookup_ssh_host_config(hostname, config):
"""
Provided only as a backward-compatible wrapper around L{SSHConfig}.
"""
return config.lookup(hostname)
示例4: _get_ssh_config
# 需要导入模块: from paramiko import config [as 别名]
# 或者: from paramiko.config import SSHConfig [as 别名]
def _get_ssh_config(key):
if not _ssh_config:
ssh_config = SSHConfig()
path = os.path.expanduser('~/.ssh/config')
if os.path.exists(path):
with open(path) as open_file:
ssh_config.parse(open_file)
# Create a fake hostname like "dev.myproject.ssha" to allow users to
# set options in ~/.ssh/config based on the environment and project.
hostname_parts = (get('config.name'), get('ssha.name'), 'ssha')
hostname = '.'.join(filter(None, hostname_parts))
result = ssh_config.lookup(hostname)
if 'identityfile' not in result:
result['identityfile'] = [
'~/.ssh/id_rsa',
'~/.ssh/id_dsa',
'~/.ssh/id_ecdsa',
'~/.ssh/id_ed25519',
]
if 'user' not in result:
user = os.environ.get('USER')
if user:
result['user'] = user
_ssh_config.update(result)
return _ssh_config.get(key, [])
示例5: lookup_ssh_host_config
# 需要导入模块: from paramiko import config [as 别名]
# 或者: from paramiko.config import SSHConfig [as 别名]
def lookup_ssh_host_config(hostname, config):
"""
Provided only as a backward-compatible wrapper around `.SSHConfig`.
"""
return config.lookup(hostname)