-
Notifications
You must be signed in to change notification settings - Fork 8.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Dynamically generate profiles from hosts in OpenSSH config files #14042
Conversation
This PR adds a new `SshHostGenerator` inbox dynamic profile generator. When run, it looks for an install of our [Win32-OpenSSH](https://github.com/PowerShell/Win32-OpenSSH) client app `ssh.exe` in all of the (official) places it gets installed. If the exe is found, the generator then looks for and parses both the user and system OpenSSH config files for valid SSH hosts. Each host is then converted into a profiles to call `ssh.exe` and connect to those hosts. Closes microsoft#9031
324182e
to
3e851a9
Compare
Tests pass, but I don't see an obvious place for adding new tests (there are no existing tests for dynamic profiles). I'm not sure what Schema needs to be updated. Working on a paired docs PR. |
de1fe23
to
bc5a6c6
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Schema: this is probably the only thing that needs to be updated there -
terminal/doc/cascadia/profiles.schema.json
Lines 27 to 34 in 657dd5f
"DynamicProfileSource": { "enum": [ "Windows.Terminal.Wsl", "Windows.Terminal.Azure", "Windows.Terminal.PowershellCore" ], "type": "string" }, - that
_
prefix thing
Other than that, this is perfect! Thank you so much!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
-- blocking for team discussion --
We've discussed this PR among the team today. We've had a history of generating too many profiles during startup which leads to usability problems when this list for instance gets to too long. For instance my list looks like that by default already when I first launch Windows Terminal: Long term we'd like to improve this by introducing a nested new tab menu like this: (See also #13763.) ...as well as adding a revamped settings UI which nests or groups profiles, removing them from the navigation view on the left. Finally, we've been thinking about not adding any generated profiles by default anymore and instead improve the settings UI in such a way that creating/cloning profiles will be much easier. So instead of adding all your SSH hosts all at once you can choose which ones are supposed to show up in your UI first. As such we'd like to hide it behind a feature flag for now similar to Would you agree with our reasoning? If not, please let us know! 🙂 |
Although I would LOVE to have this feature, as I asked in #9031 (comment), I am pleased with this decision. 👍🏻 With over 20 profiles in my |
This pull request has been automatically marked as stale because it has been marked as requiring author feedback but has not had any activity for 7 days. It will be closed if no further activity occurs within 7 days of this comment. |
Although the idea of this feature is great it would be unusable for serious users of hosts inside OpenSSH config:
|
I was not aware of the use of |
Alright, we chatted about this in sync today. Outside of that issue for profile management we've been chatting about above, this PR is pretty much good to go. So we're going to review/merge it as-is, but hide generating the profiles behind a feature flag. I'll handle adding the feature flag code, so don't worry about that. :) It'll require me to push to this branch/PR though FYI, Excited to see this land! |
In my opinion support for I think that the use of the |
FWIW, I'm not gonna hold this PR up over that. We should file a follow up, to track it, but let's not let perfect be the enemy of the good. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm cool with this behind velocity while we sort out #12584
@DHowett I'm gonna remove your block tomorrow if you don't, cause we're merging the nested menu & filtering, AND cause carlos added the velocity flag. |
Hello @DHowett! Because this pull request has the p.s. you can customize the way I help with merging this pull request, such as holding this pull request until a specific person approves. Simply @mention me (
|
Merge and iterate! |
@jonthysell thanks so much for doing this, and putting up with our quite long review cycle! |
@zadjii-msft @carlos-zamora somebody may need to merge main! I am not able to do so at the moment |
This comment has been minimized.
This comment has been minimized.
Hi everyone, very glad to have found this PR, thanks for working on this. I've been doing this with a Python script up to now: https://gist.github.com/phil-blain/2e5a294b79ec26a1729aedab010a9369. This uses the paramiko Python library to parse the SSH config file. A few things I do in my script that this PR does not do (at least from my reading of the changes):
Just a few suggestions :) EDIT a question I just had: Why not also simply look for |
This PR adds a new dynamic profile generator which creates profiles to
quickly connect to detected SSH hosts.
This PR adds a new
SshHostGenerator
inbox dynamic profile generator.When run, it looks for an install of our
Win32-OpenSSH client app
ssh.exe
in all of the (official) places it gets installed. If the exeis found, the generator then looks for and parses both the user and
system OpenSSH config files for valid SSH hosts. Each host is then
converted into a profiles to call
ssh.exe
and connect to those hosts.VALIDATION
Installed OpenSSH, configured host for alt.org NetHack server, connected
and played some NetHack from the created profile.
System32\OpenSSH
, added to PATH)(installs in
Program Files (x86)\OpenSSH
, not added to PATH)(installs in
Program Files\OpenSSH
, not added to PATH)winget install Microsoft.OpenSSH.Beta
(uses MSI from GitHub)"disabledProfileSources": ["Windows.Terminal.SSH"]
theprofiles are not generated
Closes #9031