code: private void copySlaveJarUsingSCP(TaskListener listener, String workingDirectory) throws IOException, InterruptedException {
          SCPClient scp = new SCPClient(connection);
          try {
              // check if the working directory exists
              if (connection.exec("test -d " + workingDirectory ,listener.getLogger())!=0) {
                  listener.getLogger().println(
                          Messages.SSHLauncher_RemoteFSDoesNotExist(getTimestamp(), workingDirectory));
                  // working directory doesn't exist, lets make it.
                  if (connection.exec("mkdir -p " + workingDirectory, listener.getLogger())!=0) {
                      listener.getLogger().println("Failed to create "+workingDirectory);
                  }
              }
  
              // delete the agent jar as we do with SFTP
              connection.exec("rm " + workingDirectory + SLASH_AGENT_JAR, new NullStream());
  
              // SCP it to the agent. hudson.Util.ByteArrayOutputStream2 doesn't work for this. It pads the byte array.
              listener.getLogger().println(Messages.SSHLauncher_CopyingAgentJar(getTimestamp()));
              scp.put(new Slave.JnlpJar(AGENT_JAR).readFully(), AGENT_JAR, workingDirectory, "0644");
          } catch (IOException e) {
              throw new IOException(Messages.SSHLauncher_ErrorCopyingAgentJarInto(workingDirectory), e);
          }
      }
docs: Method copies the agent jar to the remote system using scp.
  
  @param listener         The listener.
  @param workingDirectory The directory into which the agent jar will be copied.
  
  @throws IOException If something goes wrong.
  @throws InterruptedException If something goes wrong.