title: sftp java client keeps sshd process running on remote machine
body: <p>I am using the jcraft library in order to send files from one server to an other one, using scp. The code is like this</p>
  
  <pre><code>public class Scp {
   String DestinationHost;//host IP
   String DestinationUserName;//username
   String DestinationPassword;//password
   String DestinationPublicKeyFile;//public key-if any
   String DestinationDirectory;//where to save on remote 
   String SourceFile;
   /*
      setters-getters
    */
   public void send() throws  SftpException, FileNotFoundException, JSchException{
      JSch jsch = new JSch();
      Session session = null;
      session = jsch.getSession(DestinationUserName,DestinationHost,22);
      jsch.addIdentity(getDestinationPublicKeyFile(),getDestinationPassword());
  
      session.setConfig("StrictHostKeyChecking", "no");
      session.connect();      
  
      ChannelSftp channel = null;
  
      //try to connect
      channel = (ChannelSftp)session.openChannel("sftp");
      channel.connect(30000);
      channel.connect();
  
      File localFile = new File(getSourceFile());
      File remoteFile=new File(getDestinationDirectory());
      channel.cd(remoteFile.getParent());
  
      channel.put(new FileInputStream(localFile),//the source file
      remoteFile.getParentFile().getName());//the destination name(not the path)
  
      channel.disconnect();
      session.disconnect();
    }
  }
  </code></pre>
  
  <p>This is been called from an other java class, several times, each of which is creating a new object, like so</p>
  
  <pre><code>Scp scp=new Scp();
  
  scp.setDestinationHost(CopyDestHost);
  scp.setDestinationPassword(CopyDestPassword);
  scp.setDestinationPublicKeyFile(CopyDestKey);
  scp.setDestinationUserName(CopyDestUser);               
  scp.setSourceFile(temp.getAbsolutePath());
  scp.setDestinationDirectory(filepath);
  
  stream.flush();
  stream.close();
  scp.send();
  </code></pre>
  
  <p>Since i am clossing the connections using <code>channel.disconnect();</code> and <code>session.disconnect();</code> why do I see a huge list of <code>sshd</code> processes running on my remote machine hours after the connection is closed? for example</p>
  
  <pre><code>root     13251   863  0 11:54 ?        00:00:00 sshd: skaros [priv]
  user     13300 13251  0 11:54 ?        00:00:00 sshd: skaros@notty
  skaros   13301 13300  0 11:54 ?        00:00:00 /usr/lib/openssh/sftp-server
  root     14885   863  0 10:35 ?        00:00:00 sshd: skaros [priv]
  skaros   14986 14885  0 10:35 ?        00:00:00 sshd: skaros@notty
  skaros   14987 14986  0 10:35 ?        00:00:00 /usr/lib/openssh/sftp-server
  </code></pre>
  
  <p>Is that a problem? should I kill them manually? Do I just leave them like that?</p>