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

Add SSH_AUTH_SOCK support to Windows environments. #1388

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

romanZupancic
Copy link

@romanZupancic romanZupancic commented Mar 13, 2025

Name of feature:

Add environment variable SSH_AUTH_SOCK support to Windows environments.

Pain or issue this feature alleviates:

This feature will allow Windows ssh agents which run entirely within the Windows environment (like PuTTY) to work with step cli. It will allow the agents to use Named Pipes other than the default OpenSSH Agent specific pipe (\\.\\pipe\\openssh-ssh-agent).

Why is this important to the project:

SSH_AUTH_SOCK is an environment variable specifying how clients can connect and interact with an SSH agent (https://datatracker.ietf.org/doc/html/draft-ietf-sshm-ssh-agent). If it exists, clients like step cli should load ssh keys into the agent it points to. At present, it is not wholeheartedly respected on Windows systems.

The existing code (in internal/sshutil/agent_windows.go) only includes logic to handle the existence of SSH_AUTH_SOCK in Unix-like environments (such as cygwin). The existing code uses Unix pipes to connect to the agent specified by this variable (which are only available in a unix-like environment).

This PR adds functionality such that if the environment variable SSH_AUTH_SOCK is defined (i.e. not empty), step cli will attempt to connect to the agent at the path it specified with a Named Windows Pipe. If the variable is not defined, it will continue to fall back to the OpenSSH Agent specific pipe (\\.\\pipe\\openssh-ssh-agent).

This feature is specifically important to me because I'd like to use the Pageant SSH Agent. Some other programs (like WinSCP) only support Pageant, so having a method of loading keys directly through step is important.

Is there documentation on how to use this feature? If so, where?

I've added appropriate error messages. Not sure if other documentation may need to be updated!

In what environments or workflows is this feature supported?

Non Unix-like Windows environments.

Supporting links/other PRs/issues:

💔Thank you!

- Presently dialing Windows SSH agents respects the SSH_AUTH_SOCK
  environment variable only if step cli is run in specific Unix-like
  environments (i.e. cygwin). If defined, the agent specified at
  SSH_AUTH_SOCK will be dialed through a unix pipe with `net.Dial`.
  In a full Windows environment, the SSH_AUTH_SOCK variable is ignored
  and the default OpenSSH Agent pipe is dialed instead.
- But some Windows agents (like Pageant) may open Named Pipes at arbitrary paths.
- This commit adds support for SSH_AUTH_SOCK in a full Windows Context.
  So, if SSH_AUTH_SOCK is defined, the agent specified at SSH_AUTH_SOCK
  will be dialed through the Windows Named Pipe with winio.DialPipeContext.
  If SSH_AUTH_SOCK is not specified (or blank), the default
  `\\.\\pipe\\openssh-ssh-agent` will be dialed instead.
@github-actions github-actions bot added the needs triage Waiting for discussion / prioritization by team label Mar 13, 2025
@hslatman hslatman self-assigned this Mar 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs triage Waiting for discussion / prioritization by team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants