I'm happy to report that Jenkins works fine with PowerShell 7!
I have this in my connection log: [02/12/21 10:58:38] [SSH] SSH host key matches key seen previously for this host. Connection will be allowed. [02/12/21 10:58:38] [SSH] Authentication successful. [02/12/21 10:58:50] [SSH] The remote user's environment is: [91mSet-Variable: [91mCannot process command because of one or more missing mandatory parameters: Name. [0m [02/12/21 10:58:53] [SSH] Checking java version of C:\Users\jenkins/jdk/bin/java [02/12/21 10:58:57] [SSH] C:\Users\jenkins/jdk/bin/java -version returned 11.0.10. [02/12/21 10:58:57] [SSH] Starting sftp client. [02/12/21 10:58:58] [SSH] Copying latest remoting.jar... [02/12/21 10:58:59] [SSH] Copied 1,521,553 bytes. Expanded the channel window size to 4MB [02/12/21 10:58:59] [SSH] Starting agent process: cd "C:\Users\jenkins" && C:\Users\jenkins/jdk/bin/java -jar remoting.jar -workDir C:\Users\jenkins -jar-cache C:\Users\jenkins/remoting/jarCache Feb 12, 2021 9:59:02 AM org.jenkinsci.remoting.engine.WorkDirManager initializeWorkDir INFO: Using C:\Users\jenkins\remoting as a remoting work directory Feb 12, 2021 9:59:02 AM org.jenkinsci.remoting.engine.WorkDirManager setupLogging INFO: Both error and output logs will be printed to C:\Users\jenkins\remoting <===[JENKINS REMOTING CAPACITY]===>channel started Remoting version: 4.5 This is a Windows agent WARNING: An illegal reflective access operation has occurred WARNING: Illegal reflective access by org.jenkinsci.plugins.envinject.service.EnvInjectMasterEnvVarsSetter to field java.lang.reflect.Field.modifiers WARNING: Please consider reporting this to the maintainers of org.jenkinsci.plugins.envinject.service.EnvInjectMasterEnvVarsSetter WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations WARNING: All illegal access operations will be denied in a future release Agent successfully connected and online The Agent is connected, disconnect it before to try to connect it again. The An illegal reflective access operation has occurred is probably something something Java 11, and I always ignore such warnings. Maybe someone should consider reporting this to the maintainers of org.jenkinsci.plugins.envinject.service.EnvInjectMasterEnvVarsSetter? :-) This is how I configured the node with Ansible: - name: Install Win32-OpenSSH service win_chocolatey: name: openssh package_params: /SSHServerFeature state: present ignore_errors: yes - name: Install Powershell Core win_chocolatey: name: powershell-core state: present - name: Set the default SSH shell to PowerShell win_regedit: path: HKLM:\SOFTWARE\OpenSSH name: DefaultShell data: C:\Program Files\PowerShell\7\pwsh.exe The ignore_errors: yes with openssh is because I use the same Ansible playbook for Packer (which goes to AWS) and Vagrant (which is for testing on my local machine), and the local VM already has SSH running and I haven't bothered yet with debugging that, so I just ignore the error when Chcoclatey can't install OpenSSH due to port 22 already in use. But anyway: for anyone not using Ansible: you need to set the registry key HKLM:\SOFTWARE\OpenSSH to the full path of pwsh.exe. Powershell legacy and Powershell Core have a different executable name, intentionally, so they can be used side-by-side. I hope this is useful for anyone. -- Amedee On Thursday, February 11, 2021 at 11:32:53 AM UTC+1 Amedee Van Gasse wrote: > That would actually be great and very much appreciated. > > > I've been down the rabbit hole a bit further and found something that may > be of interest. > > From what I've seen from the error, Jenkins sends compound shell commands > to the node, with "&&" as pipeline chain operator. > "&&" has the same function in Bash as well as in MS-DOS. > PowerShell Windows (up to version 5 I guess) doesn't know '&&', there you > have to use '-and'. > However, PowerShell 7 (PowerShell Core, the open source cross-platform > version) does implement pipeline chain operators. > See > https://docs.microsoft.com/en-us/powershell/scripting/whats-new/what-s-new-in-powershell-70?view=powershell-7 > > I don't know if that will solve all of the issues with PowerShell, but > it's definitely worth giving a shot. > I'll try it out and report back here. > > On Wednesday, February 10, 2021 at 8:05:15 PM UTC+1 slide wrote: > >> FYI, I started to look at this again and will hopefully have a PR soon. >> >> On Tue, Feb 9, 2021, 08:07 Slide <slide...@gmail.com> wrote: >> >>> That will cause problems, the ssh-agents-plugin is not set up to handle >>> PowerShell as the default shell. I looked into it a while back but didn't >>> make good progress. >>> >>> On Tue, Feb 9, 2021 at 2:45 AM Amedee Van Gasse <amedee....@gmail.com> >>> wrote: >>> >>>> FYI PowerShell is the default SSH shell on this machine. >>>> >>>> On Tuesday, February 9, 2021 at 10:27:38 AM UTC+1 Amedee Van Gasse >>>> wrote: >>>> >>>>> I got this when connecting to a Windows node, how do I fix this? >>>>> >>>>> [02/09/21 10:20:58] [SSH] SSH host key matches key seen previously for >>>>> this host. Connection will be allowed. >>>>> [02/09/21 10:20:58] [SSH] Authentication successful. >>>>> [02/09/21 10:20:59] [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 >>>>> >>>>> [02/09/21 10:21:00] [SSH] Checking java version of >>>>> C:\Users\jenkins/jdk/bin/java >>>>> [02/09/21 10:21:01] [SSH] C:\Users\jenkins/jdk/bin/java -version >>>>> returned 11.0.10. >>>>> [02/09/21 10:21:01] [SSH] Starting sftp client. >>>>> [02/09/21 10:21:01] [SSH] Copying latest remoting.jar... >>>>> [02/09/21 10:21:02] [SSH] Copied 1,521,553 bytes. >>>>> Expanded the channel window size to 4MB >>>>> [02/09/21 10:21:02] [SSH] Starting agent process: cd >>>>> "C:\Users\jenkins" && C:\Users\jenkins/jdk/bin/java -jar remoting.jar >>>>> -workDir C:\Users\jenkins -jar-cache C:\Users\jenkins/remoting/jarCache >>>>> At line:1 char:23 >>>>> + cd "C:\Users\jenkins" && C:\Users\jenkins/jdk/bin/java -jar >>>>> remoting ... >>>>> + ~~ >>>>> The token '&&' is not a valid statement separator in this version. >>>>> + CategoryInfo : ParserError: (:) [], >>>>> ParentContainsErrorRecordException >>>>> + FullyQualifiedErrorId : InvalidEndOfLine >>>>> >>>>> Agent JVM has terminated. Exit code=1 >>>>> [02/09/21 10:21:02] Launch failed - cleaning up connection >>>>> [02/09/21 10:21:02] [SSH] Connection closed. >>>>> SSHLauncher{host='ec2-3-123-229-137.eu-central-1.compute.amazonaws.com', >>>>> port=22, credentialsId='b56e65e1-beb0-4ad3-bcaa-e9c7aea3c4f8', >>>>> jvmOptions='', javaPath='', prefixStartSlaveCmd='', >>>>> suffixStartSlaveCmd='', >>>>> launchTimeoutSeconds=60, maxNumRetries=10, retryWaitTime=15, >>>>> sshHostKeyVerificationStrategy=hudson.plugins.sshslaves.verifiers.ManuallyTrustedKeyVerificationStrategy, >>>>> >>>>> tcpNoDelay=true, trackCredentials=true} >>>>> [02/09/21 10:21:02] [SSH] Opening SSH connection to >>>>> ec2-3-123-229-137.eu-central-1.compute.amazonaws.com:22. >>>>> [02/09/21 10:21:03] [SSH] SSH host key matches key seen previously for >>>>> this host. Connection will be allowed. >>>>> [02/09/21 10:21:03] [SSH] Authentication successful. >>>>> [02/09/21 10:21:03] [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 >>>>> >>>>> [02/09/21 10:21:04] [SSH] Checking java version of >>>>> C:\Users\jenkins/jdk/bin/java >>>>> [02/09/21 10:21:04] [SSH] C:\Users\jenkins/jdk/bin/java -version >>>>> returned 11.0.10. >>>>> [02/09/21 10:21:04] [SSH] Starting sftp client. >>>>> [02/09/21 10:21:04] [SSH] Copying latest remoting.jar... >>>>> Source agent hash is D866F0B482DB94F38E49B26B465D5DB5. Installed agent >>>>> hash is D866F0B482DB94F38E49B26B465D5DB5 >>>>> Verified agent jar. No update is necessary. >>>>> Expanded the channel window size to 4MB >>>>> [02/09/21 10:21:09] [SSH] Starting agent process: cd >>>>> "C:\Users\jenkins" && C:\Users\jenkins/jdk/bin/java -jar remoting.jar >>>>> -workDir C:\Users\jenkins -jar-cache C:\Users\jenkins/remoting/jarCache >>>>> At line:1 char:23 >>>>> + cd "C:\Users\jenkins" && C:\Users\jenkins/jdk/bin/java -jar >>>>> remoting ... >>>>> + ~~ >>>>> The token '&&' is not a valid statement separator in this version. >>>>> + CategoryInfo : ParserError: (:) [], >>>>> ParentContainsErrorRecordException >>>>> + FullyQualifiedErrorId : InvalidEndOfLine >>>>> >>>>> Agent JVM has terminated. Exit code=1 >>>>> [02/09/21 10:21:10] Launch failed - cleaning up connection >>>>> [02/09/21 10:21:10] [SSH] Connection closed. >>>>> connect timed out >>>>> SSH Connection failed with IOException: "connect timed out", retrying >>>>> in 15 seconds. There are 2 more retries left. >>>>> connect timed out >>>>> SSH Connection failed with IOException: "connect timed out", retrying >>>>> in 15 seconds. There are 1 more retries left. >>>>> connect timed out >>>>> ERROR: Connection is not established! >>>>> java.lang.IllegalStateException: Connection is not established! >>>>> at >>>>> com.trilead.ssh2.Connection.getRemainingAuthMethods(Connection.java:988) >>>>> at >>>>> com.cloudbees.jenkins.plugins.sshcredentials.impl.TrileadSSHPublicKeyAuthenticator.getRemainingAuthMethods(TrileadSSHPublicKeyAuthenticator.java:88) >>>>> at >>>>> com.cloudbees.jenkins.plugins.sshcredentials.impl.TrileadSSHPublicKeyAuthenticator.canAuthenticate(TrileadSSHPublicKeyAuthenticator.java:80) >>>>> at >>>>> com.cloudbees.jenkins.plugins.sshcredentials.SSHAuthenticator.newInstance(SSHAuthenticator.java:218) >>>>> at >>>>> com.cloudbees.jenkins.plugins.sshcredentials.SSHAuthenticator.newInstance(SSHAuthenticator.java:171) >>>>> at >>>>> hudson.plugins.sshslaves.SSHLauncher.openConnection(SSHLauncher.java:865) >>>>> at hudson.plugins.sshslaves.SSHLauncher$1.call(SSHLauncher.java:436) >>>>> at hudson.plugins.sshslaves.SSHLauncher$1.call(SSHLauncher.java:423) >>>>> 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) >>>>> [02/09/21 10:24:11] Launch failed - cleaning up connection >>>>> [02/09/21 10:24:11] [SSH] Connection closed. >>>>> >>>> -- >>>> You received this message because you are subscribed to the Google >>>> Groups "Jenkins Users" group. >>>> To unsubscribe from this group and stop receiving emails from it, send >>>> an email to jenkinsci-use...@googlegroups.com. >>>> To view this discussion on the web visit >>>> https://groups.google.com/d/msgid/jenkinsci-users/c9df454f-a248-4d20-b677-52870cae84a5n%40googlegroups.com >>>> >>>> <https://groups.google.com/d/msgid/jenkinsci-users/c9df454f-a248-4d20-b677-52870cae84a5n%40googlegroups.com?utm_medium=email&utm_source=footer> >>>> . >>>> >>> >>> >>> -- >>> Website: http://earl-of-code.com >>> >> -- You received this message because you are subscribed to the Google Groups "Jenkins Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-users+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/aaba7a6f-30c1-4c8f-b624-2d25be80a9a3n%40googlegroups.com.