Allow specifying multiple matching hostnames
This commit is contained in:
parent
3f3efab221
commit
499b30d175
@ -19,9 +19,10 @@ defconf = os.path.join(config_dir, 'ssh.conf')
|
|||||||
def options_for_host(hostname: str, per_host_opts: Dict[str, SSHOptions]) -> SSHOptions:
|
def options_for_host(hostname: str, per_host_opts: Dict[str, SSHOptions]) -> SSHOptions:
|
||||||
import fnmatch
|
import fnmatch
|
||||||
matches = []
|
matches = []
|
||||||
for pat, opts in per_host_opts.items():
|
for spat, opts in per_host_opts.items():
|
||||||
if fnmatch.fnmatchcase(hostname, pat):
|
for pat in spat.split():
|
||||||
matches.append(opts)
|
if fnmatch.fnmatchcase(hostname, pat):
|
||||||
|
matches.append(opts)
|
||||||
if not matches:
|
if not matches:
|
||||||
return SSHOptions({})
|
return SSHOptions({})
|
||||||
base = matches[0]
|
base = matches[0]
|
||||||
|
|||||||
@ -26,12 +26,12 @@ agr('host', 'Host environment') # {{{
|
|||||||
opt('hostname', '*', option_type='hostname',
|
opt('hostname', '*', option_type='hostname',
|
||||||
long_text='''
|
long_text='''
|
||||||
The hostname the following options apply to. A glob pattern to match multiple
|
The hostname the following options apply to. A glob pattern to match multiple
|
||||||
hosts can be used. When not specified options apply to all hosts, until the
|
hosts can be used. Multiple hostnames can also be specified separated by spaces.
|
||||||
|
When not specified options apply to all hosts, until the
|
||||||
first hostname specification is found. Note that the hostname this matches
|
first hostname specification is found. Note that the hostname this matches
|
||||||
against is the hostname used by the remote computer, not the name you pass
|
against is the hostname used by the remote computer, not the name you pass
|
||||||
to SSH to connect to it. If you wish to include the same configuration for many
|
to SSH to connect to it. If you wish to include the same basic configuration for many
|
||||||
different hosts, you can do so with the :code:`include` directive (see :doc:`conf`),
|
different hosts, you can do so with the :code:`include` directive (see :doc:`conf`).
|
||||||
so that you need only two lines per host.
|
|
||||||
''')
|
''')
|
||||||
|
|
||||||
opt('+copy', '', option_type='copy', add_to_default=False, long_text=f'''
|
opt('+copy', '', option_type='copy', add_to_default=False, long_text=f'''
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user