OpenSSH Launch failed

Hello there,

I am trying to start agent throw OpenSSH. I have set up the private key on jenkins controller and the public on node. when i launch the agent it throw this error:

Searching for 172.16.30.144 in C:\Users\Administrator.ssh\known_hosts
Searching for 172.16.30.144:22 in C:\Users\Administrator.ssh\known_hosts
[03/11/23 20:32:29] [SSH] SSH host key matches key in Known Hosts file. Connection will be allowed.
[03/11/23 20:32:29] [SSH] Authentication successful.
[03/11/23 20:32:29] [SSH] The remote user’s environment is:
Set-Variable : Cannot process command because of one or more missing mandatory parameters: Name.
At line:1 char:1

  • set
  •   + CategoryInfo          : InvalidArgument: (:) [Set-Variable], ParameterBindingException
      + FullyQualifiedErrorId : MissingMandatoryParameter,Microsoft.PowerShell.Commands.SetVariableCommand
    
    

Checking Java version in the PATH
java : The term ‘java’ is not recognized as the name of a cmdlet, function, script file, or operable program. Check
the spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:1

  • java -version
  •   + CategoryInfo          : ObjectNotFound: (java:String) [], CommandNotFoundException
      + FullyQualifiedErrorId : CommandNotFoundException
    
    

Java is not in the PATH nor configured with the javaPath setting, Jenkins will try to guess where is Java, this guess will be removed in the future. :Launch agents via SSH
[03/11/23 20:32:30] [SSH] Checking java version of C:/tools/jenkins-agent/jdk/bin/java
[03/11/23 20:32:30] [SSH] C:/tools/jenkins-agent/jdk/bin/java -version returned 11.0.18.
[03/11/23 20:32:30] [SSH] Starting sftp client.
[03/11/23 20:32:31] [SSH] Copying latest remoting.jar…
Source agent hash is 25B899E9C1FD1001F55EF1A8DB224323. Installed agent hash is 25B899E9C1FD1001F55EF1A8DB224323
Verified agent jar. No update is necessary.
Expanded the channel window size to 4MB
[03/11/23 20:32:31] [SSH] Starting agent process: cd “C:/tools/jenkins-agent” && C:/tools/jenkins-agent/jdk/bin/java -jar remoting.jar -workDir C:/tools/jenkins-agent -jar-cache C:/tools/jenkins-agent/remoting/jarCache
At line:1 char:27

  • cd C:/tools/jenkins-agent && C:/tools/jenkins-agent/jdk/bin/java -ja …
  •                       ~~
    

The token ‘&&’ is not a valid statement separator in this version.
+ CategoryInfo : ParserError: (:slight_smile: , ParentContainsErrorRecordException
+ FullyQualifiedErrorId : InvalidEndOfLine

Agent JVM has terminated. Exit code=1
[03/11/23 20:32:31] Launch failed - cleaning up connection
[03/11/23 20:32:31] [SSH] Connection closed.

Look at the bottom of this page ssh-slaves-plugin/CONFIGURE.md at 365f5ebabeec6eb5932c7b6afed8695ba4f3a15d · jenkinsci/ssh-slaves-plugin · GitHub

If you have PowerShell as your default shell on the Windows machine, you have to add some pre-command and post-command stuff.

1 Like