RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
Bug 1759421 - Include directive in ssh_config doesn't work properly
Summary: Include directive in ssh_config doesn't work properly
Keywords:
Status: CLOSED NOTABUG
Alias: None
Product: Red Hat Enterprise Linux 8
Classification: Red Hat
Component: openssh
Version: 8.1
Hardware: All
OS: All
low
low
Target Milestone: rc
: 8.0
Assignee: Jakub Jelen
QA Contact: BaseOS QE Security Team
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2019-10-08 06:44 UTC by Renaud Métrich
Modified: 2019-10-08 10:56 UTC (History)
1 user (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2019-10-08 10:56:05 UTC
Type: Bug
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)

Description Renaud Métrich 2019-10-08 06:44:31 UTC
Description of problem:

When specifying the Include directive in ~/.ssh/config to include other files, the Host definitions in the included file are not processed if the file is included after some other Host directive in the main ~/.ssh/config file.


Version-Release number of selected component (if applicable):

All openssh versions (RHEL7, 8)


How reproducible:

Always


Steps to Reproduce:
1. Create 2 files to be included

$ cat > ~/.ssh/after.config << EOF
Host foo-after
    Hostname localhost
EOF

$ cat > ~/.ssh/before.config << EOF
Host foo-before
    Hostname localhost
EOF

$ cat > ~/.ssh/config << EOF
Include before.config
Host foo-config
    Hostname localhost
Include after.config
EOF

2. Try connecting to foo-before or foo-config (works)

$ ssh foo-before true
$ ssh foo-config true

3. Try connecting to foo-after (fails)

$ ssh foo-after true

Actual results:

ssh: Could not resolve hostname foo-after: Name or service not known

Expected results:

works


Additional info:

When connecting, the ~/.ssh/after.config file is not really included, but only parsed (from debug logs, see "parse only"):

# ssh -vvv foo-after true
OpenSSH_7.8p1, OpenSSL 1.1.1 FIPS  11 Sep 2018
debug1: Reading configuration data /root/.ssh/config
debug3: /root/.ssh/config line 1: Including file /root/.ssh/before.config depth 0
debug1: Reading configuration data /root/.ssh/before.config
debug3: /root/.ssh/config line 6: Including file /root/.ssh/after.config depth 0 (parse only)
debug1: Reading configuration data /root/.ssh/after.config
...

Comment 1 Jakub Jelen 2019-10-08 10:56:05 UTC
This is expected behavior. See the manual page for ssh_config:

>  Include directive may appear inside a Match or Host block to perform conditional inclusion.

There is a simple solution for that -- use "Match all" before the unconditional include.


Note You need to log in before you can comment on or make changes to this bug.