-
Notifications
You must be signed in to change notification settings - Fork 325
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
Add support for Win32-OpenSSH #1744
Conversation
Updates the `Beaker::Host::Windows#determine_ssh_server` method to detect when running the Win32-OpenSSH sshd based on the service's binPath. This is needed because that implementation handles backslashes differently than cygwin's sshd.
If `determine_ssh_server` returned an unknown type, then beaker failed to raise an ArgumentError. When using `raise` you can pass two arguments, the class to raise and the message, or pass an instance of an exception, e.g. ArgumentError.new("message"). This also adds tests for the other cases.
When using cygwin bash.exe, backslashes are handled differently depending on whether we're using cygwin or Windows-OpenSSH's sshd. $ ssh Administrator@win32-openssh 'cmd /c echo c:\\Windows' c:Windows $ ssh Administrator@cygwin 'cmd /c echo c:\\Windows' c:\Windows Note that Win32-OpenSSH lost the backslashes. This issue prevents beaker from installing puppet-agent on Windows 11 using Win32-OpenSSH, as it scp's a bat file to the Windows host: $ scp /tmp/install-puppet-msi-2022-06-22_18.18.04.bat20220622-2096997-1w3xtbd host.example.com:C:\Windows\TEMP\install-puppet-msi-2022-06-22_18.18.04.bat But the resulting path doesn't exist: $ cmd.exe /c "C:\Windows\TEMP\install-puppet-msi-2022-06-22_18.18.04.bat" 'C:\Windows\TEMP\install-puppet-msi-2022-06-22_18.18.04.bat' is not recognized as an internal or external command, operable program or batch file. To avoid these problems, convert backslashes to forward slashes when using Windows-OpenSSH. This way the scp and execute steps refer to the same file. This is the same solution used when using bitvise and `Beaker::Host:PSWindows` since it's `scp_separator` is '/'[1] [1] https://github.com/voxpupuli/beaker/blob/76a974f448bc49cdab69792d95ae606d2d868f50/lib/beaker/host/pswindows.rb#L28
Codecov Report
@@ Coverage Diff @@
## master #1744 +/- ##
==========================================
+ Coverage 74.77% 74.88% +0.10%
==========================================
Files 82 82
Lines 4861 4865 +4
==========================================
+ Hits 3635 3643 +8
+ Misses 1226 1222 -4
Continue to review full report at Codecov.
|
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.
The code looks good, windows is weird 🤪
Nevermind, the error was actually before that as the destination directory wasn't created correctly. |
This is working in puppet, facter & puppet-agent PRs, so going to merge |
Newer versions of Windows ship with Win32-OpenSSH (see https://github.com/PowerShell/openssh-portable) This PR makes it possible to detect when that implementation is used (based on the binary path of the
sshd
service) and it converts backslashes to forward slashes, such as when callingscp_to
. This is similar to the work that was done to support BitVise and powershell (PSWindows)