title: Unable to connect to Jenkins Agent after upgrade
body: <p>Upgraded Jenkins from 2.257 to 2.339. After the upgrade none of the nodes are able to connect to the master. Jenkins is hosted on Amazon Linux. This is error I am getting when I try to connect a node to the controller:</p>
  <p><strong>Logs from Windows Agent :</strong></p>
  <pre><code>SSHLauncher{host='172.*.*.*', port=22, credentialsId='3f7dbc2d-7850-4506-a356-24328ded5b43', jvmOptions='', javaPath='', prefixStartSlaveCmd='', suffixStartSlaveCmd='', launchTimeoutSeconds=210, maxNumRetries=10, retryWaitTime=15, sshHostKeyVerificationStrategy=hudson.plugins.sshslaves.verifiers.ManuallyTrustedKeyVerificationStrategy, tcpNoDelay=true, trackCredentials=true}
  [03/20/22 14:38:59] [SSH] Opening SSH connection to 172.*.*.*.
  [03/20/22 14:38:59] [SSH] SSH host key matches key seen previously for this host. Connection will be allowed.
  [03/20/22 14:38:59] [SSH] Authentication successful.
  [03/20/22 14:38:59] [SSH] The remote user's environment is:
  ALLUSERSPROFILE='C:\&lt;some folder&gt;'
  ANDROID_HOME='C:\&lt;some path&gt;'
  ANDROID_NDK_HOME='C:\&lt;some path&gt;'
  APPDATA='C:\Users\&lt;jenkis user&gt;\AppData\Roaming'
  BASH=/bin/bash
  BASHOPTS=cmdhist:complete_fullquote:extquote:force_fignore:hostcomplete:interactive_comments:progcomp:promptvars:sourcepath
  BASH_ALIASES=()
  BASH_ARGC=()
  BASH_ARGV=()
  BASH_CMDS=()
  BASH_EXECUTION_STRING=set
  BASH_LINENO=()
  BASH_SOURCE=()
  BASH_VERSINFO=([0]=&quot;4&quot; [1]=&quot;4&quot; [2]=&quot;12&quot; [3]=&quot;3&quot; [4]=&quot;release&quot; [5]=&quot;x86_64-unknown-cygwin&quot;)
  BASH_VERSION='4.4.12(3)-release'
  COMPUTERNAME=EC2AMAZ-ML17J1C
  COMSPEC='C:\Windows\system32\cmd.exe'
  CYGWIN=sshd
  CYG_SYS_BASHRC=1
  CommonProgramFiles='C:\Program Files\Common Files'
  CommonProgramW6432='C:\Program Files\Common Files'
  DIRSTACK=()
  EUID=197608
  GROUPS=()
  GTK_BASEPATH='C:\Program Files (x86)\GtkSharp\2.12\'
  HOME=/home/&lt;some path&gt;
  HOMEDRIVE=C:
  HOMEPATH='\cygwin64\home\&lt;some path&gt;'
  HOSTNAME=someserver
  HOSTTYPE=x86_64
  IFS=$' \t\n'
  JAVA_HOME='C:\Program Files\Java\jdk1.8.0_144'
  LOCALAPPDATA='C:\Users\&lt;somem user&gt;\AppData\Local'
  LOGNAME=&lt;login user&gt;
  LOGONSERVER='\\someserver
  M2_HOME='C:\apache-maven-3.3.9'
  MACHTYPE=x86_64-unknown-cygwin
  MAIL=/var/spool/mail//Jenkins
  MAVEN_HOME='C:\apache-maven-3.3.9'
  NUMBER_OF_PROCESSORS=4
  OPTERR=1
  OPTIND=1
  OS=Windows_NT
  OSTYPE=cygwin
  PATH=''
  PATHEXT='.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC'
  PIPESTATUS=([0]=&quot;0&quot;)
  PPID=5896
  PROCESSOR_ARCHITECTURE=AMD64
  PROCESSOR_IDENTIFIER='Intel64 Family 6 Model 85 Stepping 7, GenuineIntel'
  PROCESSOR_LEVEL=6
  PROCESSOR_REVISION=5507
  PROGRAMFILES='C:\Program Files'
  PS4='+ '
  PSModulePath='%ProgramFiles%\WindowsPowerShell\Modules;C:\Windows\system32\WindowsPowerShell\v1.0\Modules;C:\Program Files (x86)\AWS Tools\PowerShell\'
  PUBLIC='C:\Users\Public'
  PWD=/home/&lt;somepath&gt;
  ProgramData='C:\ProgramData'
  ProgramW6432='C:\Program Files'
  SHELL=/bin/bash
  SHELLOPTS=braceexpand:hashall:interactive-comments
  SHLVL=1
  SSH_AUTH_SOCK=/tmp/ssh-xQ6x4PUqHRF7/agent.34688
  SSH_CLIENT='172.*.*.* 52306 22'
  SSH_CONNECTION='172.*.*.* 52306 172.*.*.* 22'
  SYSTEMDRIVE=C:
  SYSTEMROOT='C:\Windows'
  TERM=dumb
  UID=197608
  USER=&lt;some user&gt;
  USERDOMAIN=someserver
  USERNAME=&lt;some user&gt;
  USERPROFILE='C:\Users\&lt;some user&gt;'
  VS140COMNTOOLS='C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\Tools\'
  WINDIR='C:\Windows'
  _=
  [03/20/22 14:38:59] [SSH] Checking java version of c:\&lt;some path&gt;/jdk/bin/java
  Couldn't figure out the Java version of c:\&lt;some path&gt;/jdk/bin/java
  bash: c:&lt;some path&gt;/jdk/bin/java: No such file or directory
  
  [03/20/22 14:38:59] [SSH] Checking java version of java
  [03/20/22 14:38:59] [SSH] java -version returned 1.8.0_191.
  [03/20/22 14:38:59] [SSH] Starting sftp client.
  [03/20/22 14:39:00] [SSH] Copying latest remoting.jar...
  java.io.IOException: Could not copy remoting.jar into 'c:\&lt;some path&gt;' on agent
      at hudson.plugins.sshslaves.SSHLauncher.copyAgentJar(SSHLauncher.java:702)
      at hudson.plugins.sshslaves.SSHLauncher.access$300(SSHLauncher.java:113)
      at hudson.plugins.sshslaves.SSHLauncher$1.call(SSHLauncher.java:445)
      at hudson.plugins.sshslaves.SSHLauncher$1.call(SSHLauncher.java:412)
      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)
  Caused by: java.lang.IllegalArgumentException: invalid len argument
      at com.trilead.ssh2.SFTPv3Client.read(SFTPv3Client.java:1232)
      at com.trilead.ssh2.jenkins.SFTPClient$SFTPInputStream.read(SFTPClient.java:172)
      at com.google.common.io.ByteStreams.toByteArrayInternal(ByteStreams.java:191)
      at com.google.common.io.ByteStreams.toByteArray(ByteStreams.java:238)
      at hudson.plugins.sshslaves.SSHLauncher.readInputStreamIntoByteArrayAndClose(SSHLauncher.java:760)
      at hudson.plugins.sshslaves.SSHLauncher.copyAgentJar(SSHLauncher.java:671)
      ... 7 more
  [03/20/22 14:39:00] Launch failed - cleaning up connection
  [03/20/22 14:39:00] [SSH] Connection closed.
  REST API
  Jenkins 2.339
  
  </code></pre>
  <p>I have 3 different nodes (Windows, Ubuntu and mac). I get the same error on all three:</p>
  <pre><code>Caused by: java.lang.IllegalArgumentException: invalid len argument
  
  </code></pre>
  <p>Appreciate any info to resolve this.
  Thanks</p>