-
Notifications
You must be signed in to change notification settings - Fork 86
Adds support to OpenSSH Servers on Windows. #389
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
base: main
Are you sure you want to change the base?
Conversation
a4475de to
66de4f2
Compare
|
Fixed failing test. Rebased onto the latest |
|
UPDATE: This version no longer uses Windows containers. See below. |
697626f to
7a7b3ba
Compare
- Adds Powershell scripts to install/uninstall opkssh in OpenSSH Server configuration. - Windows: use $env:ProgramData\opk\logs instead of `/var/log/`. - Windows: use $env:ProgramData\opk instead of Posix `/etc/opk/`. - Adapt permschecker to work with Windows ACLs. - Adapt OpenSSH version check to work with Windows builds. - Uses filepath.Join instead of path.Join.
b103295 to
f7b52ca
Compare
|
|
@fdcastel This is looking really nice! I saw you were doing some refactoring of permissions between windows and linux. OPKSSH doesn't handle file permissions in the most organized way. We have opkssh/commands/config/client_config.go Line 96 in 618effe
If you ended up refactoring my current code into unified permissions struct across all OPKSSH, I would not object. I've been thinking about doing some similar and it seems you probably have to do it to support windows. |
That's great news! 😄 |
|
BTW: should we consider removing the Docker container from the I’d also say the existing workflows could benefit from a little cleanup 😅. |
|
@EthanHeilman I'm considering adding a new The idea is to centralize all platform-specific permission settings within the application itself. This would simplify our installer scripts (on both Linux and Windows), which currently handle much of this logic, thereby reducing code duplication and keeping all permission management contained within the app. It could also be useful for quickly repairing user installations that (for any reason) may have become corrupted. What do you think? |
|
Sure! This entire PR (which is getting quite large, by the way) is meant to serve as a proof of concept for now. My intention isn’t to merge it as-is. Once everything is working properly and looks good, I plan to split it into several smaller PRs and rebase them as needed -- e.g. to adapt to new changes like #388. It will likely take me a few more weeks to finish, but progress is looking very promising. There’s still quite a bit of work to do, though (trying to build a good abstract layer for permissions in both Posix and Windows platforms). |
|
@EthanHeilman Just a quick follow-up: I had to put this work on hold for a while since things are hectic here toward year-end. 😅 But, just to reinforce, I’m still really interested in getting this done, and I expect to pick it back up soon (most likely at the beginning of January). I’m currently refactoring the work from this PR to make it simpler and more robust across both platforms. The updated work is happening here: https://github.com/fdcastel/opkssh/tree/issue-370 (note: this is not the same source branch as this PR).
Also, I noticed you’re doing some merges here. If you’d like, I can rebase this PR when I’m back. Best regards, and happy holidays! Fabio. |
|
Happy holidays! Looking forward to working with you when you get back in early Jan |
TL;DR
opksshin OpenSSH Server configuration.$env:ProgramData\opk\logsinstead of/var/log/.$env:ProgramData\opkinstead of/etc/opk/.permscheckerto work with Windows ACLs.path.Joinwithfilepath.Join.Fix #370.
To Do:
$env:ProgramData/opk) -- Is it acceptable?opksshconfiguration files -- is this necessary on Windows?-NoHomeProfileinstaller option)How to test
Tested on:
Long version (grab a ☕!)
I began migrating the existing
scripts/install-linux.shcode to PowerShell, aiming to maintain as much fidelity as possible.During the first run, I quickly encountered an issue with hardcoded POSIX filesystem paths. I adapted these to Windows paths to the best of my (admittedly limited) knowledge of Go 😅 (kudos to Claude Sonnet 4.5 for the assist!)
Some parts of the code depend on specific file permissions to run correctly. Initially, I tried to preserve this behavior by emulating the same permissions through Windows ACLs, hoping to keep the original Go code untouched. However, this turned out to be an ungrateful and impractical task, so I eventually abandoned that path.
A few smaller issues also came up, such as differences in version string formats between Windows builds. I adjusted the Go code to handle those as well.
Then I discovered a major difference in the OpenSSH Server shipped with Windows Server 2025: This PR, merged on March 26, 2021, enables the use of
AuthorizedKeysCommandUser = System, eliminating the need to create a dedicated user for runningopkssh.Browsing the Win32-OpenSSH repository, I couldn’t find a clear mapping between specific PRs and releases. However, based on the PR’s merge date and the release history
it’s reasonable to assume that versions
8.9.0.0and up includes this change.Unfortunately, it seems that all versions shipped with Windows prior to Server 2025 are earlier than this one. I added a safeguard to detect this condition and alert the user, instructing them to use the appropriate CLI option to create the
opksshuserwhen necessary.Finally, modifying the system PATH on Windows is not exactly straightforward. I updated the script to handle PATH expansion correctly, avoiding one of Windows’ many quirks.
And so… this is it! Now,
But... hey! It's working. 😄