Ignore hostname directives when using overrides

This commit is contained in:
Kovid Goyal 2022-03-15 10:38:03 +05:30
parent 52da68876d
commit 9b0bd81661
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
2 changed files with 4 additions and 2 deletions

View File

@ -61,7 +61,7 @@ Additionally, you can pass config options on the command line:
The :code:`--kitten` argument can be specified multiple times, with directives
from :file:`ssh.conf`. These are merged with :file:`ssh.conf` as if they were
appended to the end of that file. They apply only to the host being SSHed to
by this invocation.
by this invocation, so any :opt:`hostname` directives are ignored.
.. note::

View File

@ -552,7 +552,9 @@ def run_ssh(ssh_args: List[str], server_args: List[str], found_extra_args: Tuple
pat = re.compile(r'^([a-zA-Z0-9_]+)[ \t]*=')
for i, a in enumerate(found_extra_args):
if i % 2 == 1:
overrides.append(pat.sub(r'\1 ', a.lstrip()))
aq = pat.sub(r'\1 ', a.lstrip())
if aq.split(maxsplit=1)[0] != 'hostname':
overrides.append(aq)
if overrides:
overrides.insert(0, f'hostname {uname}@{hostname_for_match}')
so = init_config(overrides)