本文整理匯總了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)