-
Notifications
You must be signed in to change notification settings - Fork 181
Support OpenSSH-Agent on Windows #963
Description
Firstly, huge thanks for maintaining this library!
Main question
Currently, the OpenSSH agent on Windows is not supported. My question is whether there is a way to implement support for this in the near future. From my research (see below), this should not be particularly difficult, as the main logic already exists. One would only need to adapt SSHAgentConnector.java or implement a new, separate AgentConnector.
Some technical research
Under Linux/Unix, the OpenSSH agent exposes its API using a Unix domain socket.
The path of the Unix socket is stored in the environment variable SSH_AUTH_SOCK.
Under Windows, it exposes the API using a Windows named pipe.
The name of the pipe is fixed as \\.\pipe\openssh-ssh-agent and can be accessed more or less like a file.
Both implementations use exactly the same protocol, which means that we don’t need to change any underlying logic—only how we actually communicate with the SSH agent.
There already exists an AgentConnector that implements support for the SSH agent on Unix: SSHAgentConnector.java. This class uses java.nio.channels.SocketChannel to connect to the exposed Unix socket and can therefore query the SSH agent. However, this approach does not work on Windows.
Proposed solution
Create a new AgentConnector that uses java.nio.channels.FileChannel instead of java.nio.channels.SocketChannel. FileChannels are compatible with Windows named pipes. One could open the FileChannel like this:
new RandomAccessFile(DEFAULT_OPENSSH_AGENT_NAMED_PIPE, "rw").getChannel();and then use it almost exactly the same way as a SocketChannel.
I already have a working implementation that performs very well for my use case: bananensplit@f384f40
I am very eager to contribute, but it would be great to hear from someone with domain-specific knowledge and experience and get feedback on whether this is a good approach.
P.S. I am new to open source, so sorry if I missed something important 🙂