Skip to content

support ssh config include directive#1892

Closed
jsiverskog wants to merge 1 commit intoparamiko:mainfrom
jsiverskog:support_config_includes
Closed

support ssh config include directive#1892
jsiverskog wants to merge 1 commit intoparamiko:mainfrom
jsiverskog:support_config_includes

Conversation

@jsiverskog
Copy link
Copy Markdown

@jsiverskog jsiverskog commented Aug 11, 2021

this is heavily based on the work by Fabien Di Tore fabien@ditore.ch.

this is based on #872 , but has been cleaned up, tested and docs added.

this is heavily based on the work by Fabien Di Tore <fabien@ditore.ch>.
@danihodovic
Copy link
Copy Markdown

👏

@PeterJCLaw
Copy link
Copy Markdown

Have tested this and can confirm it works.
Test was rebased on 9151b5a.
Python 3.8 on Ubuntu, test also involved wildcard matching and proxyjump.

@bitprophet or maybe @ploxiln it would be great if you had time to review this PR?

@endremborza
Copy link
Copy Markdown

It would be lovely if this could be merged, a nice, tested, and documented solution for a problem quite a few of us hack around.

@bskinn
Copy link
Copy Markdown
Contributor

bskinn commented Oct 18, 2022

Labeled and flagged for bitprophet review.

Unfortunately, I can't provide a timeline for the review on this, as bitprophet is neck-deep in dropping Python 2 and updating to modern Sphinx for his various projects. We will get to the point of considering other feature adds like this; I just can't say when.

path = value
# According to SSH documentation if the path is relative,
# we look forward in ~/.ssh
if (not os.path.isabs(path)) and path[0] != '~':
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

path.startswith('~') would be more pythonic here...

"config file: %s" % filename)
with open(filename) as fd:
parsed_files.append(filename)
self.parse(fd, parsed_files)
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i'm trying to wrap my head around the scope of parsed_files here and it hurts a little. it seems like it's limited to the caller function, so in theory you could still create a loop where file A includes file B includes file C includes file A, and not be detected... does that make sense?

i wonder if a class variable should be used here instead, in other words. i understand it would break parsing the same file multiple times, but is that even supported?

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this catches a circular inclusion, but a test case would be nice and would make it clear.

# Expand the user home path
path = os.path.expanduser(path)
if parsed_files is None:
parsed_files = []
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wouldn't a set() be more appropriate here?


result = self.config.lookup("example.org")
assert result["hostname"] == "example.org"
assert result["user"] == "exampleuser2"
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe we should test the include loops here to clarify the problem we're trying to solve with the parsed_files detection above...

@anarcat
Copy link
Copy Markdown

anarcat commented Apr 4, 2023

This looks like good progress from #872, and from what I can tell, it addresses all the issues raised there.

I'd still like to see more unit tests, namely for the glob pattern bug identified in #872 (comment) which is claimed to be fixed, but not demonstrated by the test suite... Having a test for the exception being correctly raised on loops would be nice too, as mentioned above.

Thanks!

@anarcat
Copy link
Copy Markdown

anarcat commented Apr 4, 2023

Oh, and also this PR should close #1609.

@scratchmex
Copy link
Copy Markdown

Sorry for the ping but I don't understand how has been +4 years to get this merged. This PR is ready to merge. @bskinn @bitprophet

@bskinn
Copy link
Copy Markdown
Contributor

bskinn commented Aug 25, 2023

No worries, @scratchmex, thanks for checking in and expressing interest in the PR. Definitely helps to know where there's still active interest.

The delay is due to several factors.

  • bitprophet only has a certain allocation per week for open source, and has multiple projects to maintain with that allocation (paramiko, invoke, fabric, and others).
  • He had to run a major modernization campaign (dropping Py2 and older Py3, and upgrading several other things) across all those projects, which ran through much of 2022.
  • Since then, a lot of his paramiko focus has been on the key/auth overhaul of Key handling is terribad #387 & Authentication fails with more than one key in agent #23 & related, still progressing in stages.
  • Prior to both of these, before he recruited triagers (👋 hi!), he was also shouldering the full load of ticket handling across all the projects.
  • Life stuff. Nuff said.

We'll get this evaluated and merged when we can. Still no guarantees on that timing, unfortunately.

I'll take a close look next time I'm at-keyboard, to see if there's anything else needing doing before flagging it for bitprophet.

@anarcat
Copy link
Copy Markdown

anarcat commented Aug 25, 2023

Sorry for the ping but I don't understand how has been +4 years to get this merged. This PR is ready to merge. @bskinn @bitprophet

I'm not sure if this is a rhetorical question or not, but I'll assume you're genuinely wondering why this is not merged.

First, GitHub says, right there above the comment field, that "This branch has conflicts that must be resolved", so that needs to be fixed, normally by the submitter.

Then two people reviewed this code and one (myself) found a few improvements that could be done to the code for it to be more readable. Not a blocker, but typically this is the kind of stuff you fix before merging and maintainers (at least in my case, I'm not a maintainer here, but in my projects) tend to disregard PRs with pending comments like this that don't have feedback from the submitter.

So this needs some ACK or NACK from @jsiverskog at the very least. Otherwise, anyone else can also take this patch, improve on it, and submit it as a separate PR, and I'm sure the fine folks here will eventually take a look.

@mrmeszaros
Copy link
Copy Markdown

@anarcat @jsiverskog I am missing this feature, so I can try to finish this.
would You be okay with that?

@jsiverskog
Copy link
Copy Markdown
Author

@mrmeszaros : of course. i don't use paramiko myself anymore.

@mrmeszaros
Copy link
Copy Markdown

Okay, so after reading into the specs and experimenting with dumping custom configs with ssh -G <TEST_HOST> it seems to me that a proper implementation would be a lot bigger than a weekend job.

I am still working on it, will publish a PR in the upcoming week hopefully :)

@jsiverskog jsiverskog closed this by deleting the head repository Jan 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants