Jenkins主节点无法与安装OpenSSH的Windows 10从节点建立会话
I've installed the latest test build of OpenSSH for Windows on my Windows 10 machine, and I'm trying to configure it as a Jenkins slave node. The Jenkins master logs show SSH authentication succeeds, but the connection terminates unexpectedly when launching the slave.jar process. Here's the relevant log output:
[05/14/18 22:46:45] [SSH] Opening SSH connection to 10.10.10.10:22. [05/14/18 22:46:45] [SSH] WARNING: SSH Host Keys are not being verified. Man-in-the-middle attacks may be possible against this connection. [05/14/18 22:46:45] [SSH] Authentication successful. [05/14/18 22:46:45] [SSH] The remote user's environment is: .... [05/14/18 22:46:45] [SSH] Checking java version of java [05/14/18 22:46:45] [SSH] java -version returned 1.8.0_151. [05/14/18 22:46:45] [SSH] Starting sftp client. [05/14/18 22:46:45] [SSH] Copying latest slave.jar... [05/14/18 22:46:45] [SSH] Copied 762,466 bytes. Expanded the channel window size to 4MB [05/14/18 22:46:45] [SSH] Starting slave process: cd "C:\jenkins" && java -jar slave.jar -jar-cache "C:\jenkins\remoting\jarCache" <===[JENKINS REMOTING CAPACITY]===> <===[JENKINS REMOTING CAPACITY]===> ERROR: Unexpected error in launching a slave. This is probably a bug in Jenkins. hudson.remoting.RequestAbortedException Exception in thread "main" java.io.EOFException: unexpected stream termination ERROR: Connection terminated at hudson.remoting.ChannelBuilder.negotiate(ChannelBuilder.java:408) at hudson.remoting.Request.call(Request.java:176) java.io.EOFException at java.io.ObjectInputStream$PeekInputStream.readFully(ObjectInputStream.java:2671) at java.io.ObjectInputStream$BlockDataInputStream.readShort(ObjectInputStream.java:3146) at java.io.ObjectInputStream.readStreamHeader(ObjectInputStream.java:858) at java.io.ObjectInputStream.<init>(ObjectInputStream.java:354) at hudson.remoting.ObjectInputStreamEx.<init>(ObjectInputStreamEx.java:48) at hudson.remoting.AbstractSynchronousByteArrayCommandTransport.read(AbstractSynchronousByteArrayCommandTransport.java:35) at hudson.remoting.SynchronousCommandTransport$ReaderThread.run(SynchronousCommandTransport.java:63) Caused: java.io.IOException: Unexpected termination of the channel at hudson.remoting.SynchronousCommandTransport$ReaderThread.run(SynchronousCommandTransport.java:77) at hudson.remoting.Channel.call(Channel.java:951) at hudson.remoting.ChannelBuilder.build(ChannelBuilder.java:353) at hudson.slaves.SlaveComputer.setChannel(SlaveComputer.java:549) at hudson.slaves.SlaveComputer.setChannel(SlaveComputer.java:416) at hudson.plugins.sshslaves.SSHLauncher.startSlave(SSHLauncher.java:1110) at hudson.plugins.sshslaves.SSHLauncher.access$500(SSHLauncher.java:148) at hudson.plugins.sshslaves.SSHLauncher$2.call(SSHLauncher.java:845) at hudson.plugins.sshslaves.SSHLauncher$2.call(SSHLauncher.java:820) at java.util.concurrent.FutureTask.run(FutureTask.java:266) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) at java.lang.Thread.run(Thread.java:748) at hudson.remoting.Launcher.main(Launcher.java:743) at hudson.remoting.Launcher.runWithStdinStdout(Launcher.java:691) at hudson.remoting.Launcher.run(Launcher.java:373)[05/14/18 22:46:47] Launch failed - cleaning up connection at hudson.remoting.Launcher.main(Launcher.java:283) [05/14/18 22:46:47] [SSH] Connection closed.
I can see SSH auth works fine, but the slave process crashes immediately with an EOFException. I'm not sure what troubleshooting steps to take next—has anyone run into similar issues with Windows 10, OpenSSH (test builds), and Jenkins slaves?
I’ve hit this exact issue with the early test builds of OpenSSH for Windows and Jenkins. The root cause usually boils down to how OpenSSH handles console output/input redirection on Windows, which clashes with Jenkins’ remoting protocol. Here’s what I recommend checking step by step:
Switch to a stable OpenSSH build
The test builds often have bugs around PTY allocation and stream handling. Microsoft’s stable release of OpenSSH for Windows (available via Settings > Apps > Optional Features) fixes most of these issues. Uninstall the test build first, then install the stable version through Windows Features.Disable PTY allocation in Jenkins
Go to your slave node configuration in Jenkins, under the "Launch method" > "SSH" settings, check the box for "Disable pseudo-terminal allocation". The test OpenSSH builds don’t handle PTYs correctly for non-interactive sessions like Jenkins uses, which causes the stream termination error.Verify the
slave.jarexecution command
Sometimes the default command uses syntax that doesn’t play well with OpenSSH’s Windows shell. Try modifying the launch command to explicitly usecmd.exeto run the jar:cmd /c cd "C:\jenkins" && java -jar slave.jar -jar-cache "C:\jenkins\remoting\jarCache"OpenSSH’s default shell might be using PowerShell, which can have different behavior with
cdand command chaining. Forcingcmd.exeensures compatibility with the standard Jenkins command.Check file permissions on the Jenkins slave directory
Make sure the user you’re using for SSH has full read/write access toC:\jenkinsand all subdirectories. TheEOFExceptioncan also happen if the slave process can’t write to the jar cache or log files.Test the slave command manually over SSH
Log into the Windows machine via SSH using the same user Jenkins uses, and run the exactslave.jarcommand yourself. If you see errors or the process exits immediately, that’ll give you more clues—like missing Java environment variables, or issues with the jar file itself.
I fixed my setup by switching to the stable OpenSSH build and disabling PTY allocation. Give these steps a shot, they should cover most of the common causes for this error.
内容的提问来源于stack exchange,提问作者nradev

