Skip to content

Add windows ssh - #519

Open
Cristi1324 wants to merge 8 commits into
cloudbase:mainfrom
Cristi1324:add-windows-ssh
Open

Cristi1324 wants to merge 8 commits into
cloudbase:mainfrom
Cristi1324:add-windows-ssh

Conversation

@Cristi1324

@Cristi1324 Cristi1324 commented Sep 7, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • [windows_minion] connection_type defaults to ssh.
  • ssh uses port 22. winrm uses port 5986.
  • A missing port still selects WinRM.
  • A minion that is already deployed keeps the port saved in connection_info.
  • OS morphing uses SSH when the port is not 5986, and WinRM when the port is 5986.
  • poll_instance_until_reachable() follows that same port rule. SSH runs exit 0. WinRM runs whoami.
  • Core returns the OpenSSH guest script. The provider runs that script and opens TCP 22.

Merge with: https://github.com/cloudbase/coriolis-docker/pull/11
Provider PRs are optional.

@Cristi1324
Cristi1324 force-pushed the add-windows-ssh branch 6 times, most recently from 77cd612 to 410335f Compare September 9, 2026 13:21
@Cristi1324
Cristi1324 marked this pull request as ready for review September 9, 2026 13:30
@Cristi1324 Cristi1324 self-assigned this Sep 30, 2026
@Cristi1324
Cristi1324 force-pushed the add-windows-ssh branch 2 times, most recently from 6b4eb45 to 3536313 Compare October 1, 2026 12:55
@fabi200123
fabi200123 self-requested a review October 15, 2026 13:18

@fabi200123 fabi200123 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Would like someone else to take a look again over this! But besides the account_line = "net.exe user %s %s" % (username, password) LGTM


@mock.patch.object(wsman.WSManConnection, "from_connection_info")
@mock.patch.object(windows_ssh.WindowsSSHConnection, "from_connection_info")
def test_from_connection_info_ssh(self, mock_ssh, mock_winrm):

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I would also add a test that uses the key. From what I see you only have 1 that uses the password

)
account_line = ""
if username is not None:
account_line = "net.exe user %s %s" % (username, password)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Just for safety can you add a check before this that the password doesn't have any spaces in it? If by any chance a password like "hello there" gets sent to net.exe user <username> hello there it will fail the command.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The password requirements are already handled by the providers. Most, if not all providers that use this script with password already generate or allow passwords that do not contain spaces.

Comment thread coriolis/windows_conn.py
WINRM_HTTPS_PORT = 5986


def uses_winrm(connection_info):

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think checking on an extra protocol key would be better than just checking on the port number. Then the providers can explicitly set the protocol when it supports/prefers it.
This method could've been simply return connection_info.get('protocol', WINRM_CONSTANT)

Then you won't have extra checks for protocol either in _protocol_from_connection_info for example.
Maybe even rename this method to get_protocol and then it's super clear what it should return and used for.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Since this comment, a new core option [windows_minion] connection_type, has been added. This is used to decide if the provider should use winrm or ssh for windows worker. Currently it is set to ssh by default, but if minion_port() is not called by the provider, it'll still use winrm.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The port no. has nothing to do with the protocol type. We shouldn't assume default ports are being used, I can literally set 22 to the winrm listener (or vice-versa) - and yes, I know thus far we assumed, but if we should plan on supporting custom port numbers, we should at least prepare this feature to be extensible in that direction. I think we should make the port customizable at some point, therefore we'll need 2 options. One for protocol, one for port, and we use default protocol ports in case it's not customized.

For this PR, we can go with only protocol and always use default ports. For future, I'd like to see customizable ports option.

Comment thread coriolis/windows_conn.py
WINRM_HTTPS_PORT = 5986


def uses_winrm(connection_info):

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The port no. has nothing to do with the protocol type. We shouldn't assume default ports are being used, I can literally set 22 to the winrm listener (or vice-versa) - and yes, I know thus far we assumed, but if we should plan on supporting custom port numbers, we should at least prepare this feature to be extensible in that direction. I think we should make the port customizable at some point, therefore we'll need 2 options. One for protocol, one for port, and we use default protocol ports in case it's not customized.

For this PR, we can go with only protocol and always use default ports. For future, I'd like to see customizable ports option.

@Cristi1324
Cristi1324 marked this pull request as draft October 27, 2026 09:26
@Cristi1324
Cristi1324 force-pushed the add-windows-ssh branch 2 times, most recently from a494ffb to 8c81098 Compare October 27, 2026 12:45
@Cristi1324
Cristi1324 marked this pull request as ready for review October 28, 2026 11:21
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.

3 participants