Skip to content
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

feat(provider): add support for ssh-agent on Windows #1270

Merged
merged 6 commits into from
May 10, 2024
Merged

Conversation

Sparta142
Copy link
Contributor

@Sparta142 Sparta142 commented May 8, 2024

Contributor's Note

  • I have added / updated documentation in /docs for any user-facing features or additions.
  • I have added / updated acceptance tests in /fwprovider/tests for any new or updated resources / data sources.
  • I have ran make example to verify that the change works as expected.

Proof of Work

Community Note

  • Please vote on this pull request by adding a 👍 reaction to the original pull request comment to help the community and maintainers prioritize this request
  • Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for pull request followers and do not help prioritize the request

Closes #1257

Signed-off-by: Brian Karshick <Sparta142@users.noreply.github.com>
Signed-off-by: Brian Karshick <Sparta142@users.noreply.github.com>
@Sparta142
Copy link
Contributor Author

One concern I had: ssh-agent on Windows doesn't set the SSH_AUTH_SOCK env, which might be surprising behavior to some users.

A couple of possible solutions: either add a fallback to \\.\pipe\openssh-ssh-agent on Windows like other SSH binaries do, or make a note of this in the docs. Any opinion?

Signed-off-by: Brian Karshick <Sparta142@users.noreply.github.com>
Signed-off-by: Brian Karshick <Sparta142@users.noreply.github.com>
@Sparta142
Copy link
Contributor Author

@bpg For consistency, I think assuming the socket path (if the user doesn't provide one) is the right behavior. I made a note of this in the documentation.

Copy link
Owner

@bpg bpg left a comment

Choose a reason for hiding this comment

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

Hi @Sparta142, thanks a lot for contributing this!

I've made a few comments, could you please take a look?

Other than that, it is good to go! 🙂

docs/index.md Outdated Show resolved Hide resolved
Comment on lines 120 to 124
// On Windows, binaries using SSH typically assume a hardcoded name for the ssh-agent socket
if runtime.GOOS == "windows" && sshAgentSocket == "" {
sshAgentSocket = `\\.\pipe\openssh-ssh-agent`
}

Copy link
Owner

@bpg bpg May 10, 2024

Choose a reason for hiding this comment

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

I think it would be better to move this block to windows-specific proxmox/ssh/client_windows.go, inside the dialSocket func

Copy link
Contributor Author

Choose a reason for hiding this comment

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

dialSocket will never get an empty address because of this:

if c.agentSocket == "" {
return nil, errors.New("failed connecting to SSH agent socket: the socket file is not defined, " +
"authentication will fall back to password")
}

What if I change this so that it fills in the default socket address on Windows, and returns the error otherwise?

Copy link
Owner

Choose a reason for hiding this comment

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

Ah, good point, missed that. This check can be moved into platform-specific dialSocket as well. So if address is missing we'll supply the default value on Windows or throw an error on other platforms.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Made the change, let me know what you think

@bpg bpg added the ⌛ pending author's response Requested additional information from the reporter label May 10, 2024
@Sparta142 Sparta142 marked this pull request as ready for review May 10, 2024 01:27
Signed-off-by: Brian Karshick <Sparta142@users.noreply.github.com>
Signed-off-by: Brian Karshick <Sparta142@users.noreply.github.com>
Copy link
Owner

@bpg bpg left a comment

Choose a reason for hiding this comment

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

LGTM! 🚀

@bpg bpg removed the ⌛ pending author's response Requested additional information from the reporter label May 10, 2024
@bpg bpg merged commit ccf4834 into bpg:main May 10, 2024
7 checks passed
@bpg
Copy link
Owner

bpg commented May 10, 2024

@all-contributors please add @Sparta142 for code

Copy link
Contributor

@bpg

I've put up a pull request to add @Sparta142! 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support ssh-agent on Windows
2 participants