title: SFTP File Transfer not being received by client
body: <p>We recently performed a new deployment of our system which included an upgrade of Apache Commons VFS from 1.1 to 2.0. Since the deployment our client has said they are no longer receiving a file that is generated by our system on a daily basis and transferred to their server over sftp. All of our logs seem to indicate no problem:</p>
  
  <pre><code>DEBUG 2019-05-06 16:30:22,237 VfsLog:70 debug-&gt; Using "/home/tomcat/var/tomcat/temp/vfs_cache" as temporary files store.
  DEBUG 2019-05-06 16:30:22,248 VfsLog:70 debug-&gt; Skipping provider "org.apache.commons.vfs2.provider.webdav.WebdavFileProvider" because required class "org.apache.jackrabbit.webdav.client.methods.DavMethod" is not available.
  DEBUG 2019-05-06 16:30:22,250 VfsLog:70 debug-&gt; Skipping provider "org.apache.commons.vfs2.provider.hdfs.HdfsFileProvider" because required class "org.apache.hadoop.fs.FileSystem" is not available.
  DEBUG 2019-05-06 16:30:22,262 Transporter:525 getFSOptions-&gt; Not using strict host checking
  DEBUG 2019-05-06 16:30:22,262 Transporter:528 getFSOptions-&gt; user dir as root? true
  DEBUG 2019-05-06 16:30:22,263 Transporter:214 transportOutbound-&gt; Attempting to write to remote file [server]/[file].pgp
  DEBUG 2019-05-06 16:30:22,264 VfsLog:70 debug-&gt; Using "/home/tomcat/var/tomcat/temp/vfs_cache" as temporary files store.
  DEBUG 2019-05-06 16:30:22,267 VfsLog:70 debug-&gt; Skipping provider "org.apache.commons.vfs2.provider.webdav.WebdavFileProvider" because required class "org.apache.jackrabbit.webdav.client.methods.DavMethod" is not available.
  DEBUG 2019-05-06 16:30:22,268 VfsLog:70 debug-&gt; Skipping provider "org.apache.commons.vfs2.provider.hdfs.HdfsFileProvider" because required class "org.apache.hadoop.fs.FileSystem" is not available.
  INFO  2019-05-06 16:30:22,372 SftpClientFactory$JSchLogger:324 log-&gt; Connecting to [server] port 22
  INFO  2019-05-06 16:30:22,394 SftpClientFactory$JSchLogger:324 log-&gt; Connection established
  INFO  2019-05-06 16:30:22,398 SftpClientFactory$JSchLogger:324 log-&gt; Remote version string: SSH-2.0-Maverick_SSHD
  INFO  2019-05-06 16:30:22,398 SftpClientFactory$JSchLogger:324 log-&gt; Local version string: SSH-2.0-JSCH-0.1.54
  INFO  2019-05-06 16:30:22,399 SftpClientFactory$JSchLogger:324 log-&gt; CheckCiphers: aes256-ctr,aes192-ctr,aes128-ctr,aes256-cbc,aes192-cbc,aes128-cbc,3des-ctr,arcfour,arcfour128,arcfour256
  INFO  2019-05-06 16:30:22,430 SftpClientFactory$JSchLogger:324 log-&gt; CheckKexes: diffie-hellman-group14-sha1,ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521
  INFO  2019-05-06 16:30:22,525 SftpClientFactory$JSchLogger:324 log-&gt; CheckSignatures: ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521
  INFO  2019-05-06 16:30:22,535 SftpClientFactory$JSchLogger:324 log-&gt; SSH_MSG_KEXINIT sent
  INFO  2019-05-06 16:30:22,536 SftpClientFactory$JSchLogger:324 log-&gt; SSH_MSG_KEXINIT received
  INFO  2019-05-06 16:30:22,536 SftpClientFactory$JSchLogger:324 log-&gt; kex: server: diffie-hellman-group1-sha1,diffie-hellman-group-exchange-sha1
  INFO  2019-05-06 16:30:22,537 SftpClientFactory$JSchLogger:324 log-&gt; kex: server: ssh-rsa
  INFO  2019-05-06 16:30:22,537 SftpClientFactory$JSchLogger:324 log-&gt; kex: server: aes256-cbc,aes192-cbc,aes128-cbc
  INFO  2019-05-06 16:30:22,538 SftpClientFactory$JSchLogger:324 log-&gt; kex: server: aes256-cbc,aes192-cbc,aes128-cbc
  INFO  2019-05-06 16:30:22,539 SftpClientFactory$JSchLogger:324 log-&gt; kex: server: hmac-sha1,hmac-sha1-96,hmac-md5-96
  INFO  2019-05-06 16:30:22,539 SftpClientFactory$JSchLogger:324 log-&gt; kex: server: hmac-sha1,hmac-sha1-96,hmac-md5-96
  INFO  2019-05-06 16:30:22,540 SftpClientFactory$JSchLogger:324 log-&gt; kex: server: none
  INFO  2019-05-06 16:30:22,540 SftpClientFactory$JSchLogger:324 log-&gt; kex: server: none
  INFO  2019-05-06 16:30:22,541 SftpClientFactory$JSchLogger:324 log-&gt; kex: server: 
  INFO  2019-05-06 16:30:22,541 SftpClientFactory$JSchLogger:324 log-&gt; kex: server: 
  INFO  2019-05-06 16:30:22,542 SftpClientFactory$JSchLogger:324 log-&gt; kex: client: ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group14-sha1,diffie-hellman-group-exchange-sha256,diffie-hellman-group-exchange-sha1,diffie-hellman-group1-sha1
  INFO  2019-05-06 16:30:22,543 SftpClientFactory$JSchLogger:324 log-&gt; kex: client: ssh-rsa,ssh-dss,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521
  INFO  2019-05-06 16:30:22,543 SftpClientFactory$JSchLogger:324 log-&gt; kex: client: aes128-ctr,aes128-cbc,3des-ctr,3des-cbc,blowfish-cbc,aes192-ctr,aes192-cbc,aes256-ctr,aes256-cbc
  INFO  2019-05-06 16:30:22,544 SftpClientFactory$JSchLogger:324 log-&gt; kex: client: aes128-ctr,aes128-cbc,3des-ctr,3des-cbc,blowfish-cbc,aes192-ctr,aes192-cbc,aes256-ctr,aes256-cbc
  INFO  2019-05-06 16:30:22,544 SftpClientFactory$JSchLogger:324 log-&gt; kex: client: hmac-md5,hmac-sha1,hmac-sha2-256,hmac-sha1-96,hmac-md5-96
  INFO  2019-05-06 16:30:22,545 SftpClientFactory$JSchLogger:324 log-&gt; kex: client: hmac-md5,hmac-sha1,hmac-sha2-256,hmac-sha1-96,hmac-md5-96
  INFO  2019-05-06 16:30:22,545 SftpClientFactory$JSchLogger:324 log-&gt; kex: client: none
  INFO  2019-05-06 16:30:22,546 SftpClientFactory$JSchLogger:324 log-&gt; kex: client: none
  INFO  2019-05-06 16:30:22,547 SftpClientFactory$JSchLogger:324 log-&gt; kex: client: 
  INFO  2019-05-06 16:30:22,547 SftpClientFactory$JSchLogger:324 log-&gt; kex: client: 
  INFO  2019-05-06 16:30:22,548 SftpClientFactory$JSchLogger:324 log-&gt; kex: server-&gt;client aes128-cbc hmac-sha1 none
  INFO  2019-05-06 16:30:22,548 SftpClientFactory$JSchLogger:324 log-&gt; kex: client-&gt;server aes128-cbc hmac-sha1 none
  INFO  2019-05-06 16:30:22,567 SftpClientFactory$JSchLogger:324 log-&gt; SSH_MSG_KEX_DH_GEX_REQUEST(1024&lt;2048&lt;2048) sent
  INFO  2019-05-06 16:30:22,568 SftpClientFactory$JSchLogger:324 log-&gt; expecting SSH_MSG_KEX_DH_GEX_GROUP
  INFO  2019-05-06 16:30:22,591 SftpClientFactory$JSchLogger:324 log-&gt; SSH_MSG_KEX_DH_GEX_INIT sent
  INFO  2019-05-06 16:30:22,592 SftpClientFactory$JSchLogger:324 log-&gt; expecting SSH_MSG_KEX_DH_GEX_REPLY
  INFO  2019-05-06 16:30:22,620 SftpClientFactory$JSchLogger:324 log-&gt; ssh_rsa_verify: signature true
  INFO  2019-05-06 16:30:22,622 SftpClientFactory$JSchLogger:324 log-&gt; Host '[server]' is known and matches the RSA host key
  INFO  2019-05-06 16:30:22,623 SftpClientFactory$JSchLogger:324 log-&gt; SSH_MSG_NEWKEYS sent
  INFO  2019-05-06 16:30:22,624 SftpClientFactory$JSchLogger:324 log-&gt; SSH_MSG_NEWKEYS received
  INFO  2019-05-06 16:30:22,632 SftpClientFactory$JSchLogger:324 log-&gt; SSH_MSG_SERVICE_REQUEST sent
  INFO  2019-05-06 16:30:22,635 SftpClientFactory$JSchLogger:324 log-&gt; SSH_MSG_SERVICE_ACCEPT received
  INFO  2019-05-06 16:30:22,642 SftpClientFactory$JSchLogger:324 log-&gt; Authentications that can continue: publickey,keyboard-interactive,password
  INFO  2019-05-06 16:30:22,642 SftpClientFactory$JSchLogger:324 log-&gt; Next authentication method: publickey
  INFO  2019-05-06 16:30:22,719 SftpClientFactory$JSchLogger:324 log-&gt; Authentications that can continue: password
  INFO  2019-05-06 16:30:22,719 SftpClientFactory$JSchLogger:324 log-&gt; Next authentication method: password
  INFO  2019-05-06 16:30:22,736 SftpClientFactory$JSchLogger:324 log-&gt; Authentication succeeded (password).
  DEBUG 2019-05-06 16:30:22,758 SoftRefFilesCache:130 putFile-&gt; putFile: sftp://[user]:***@[server]/[filename].pgp
  DEBUG 2019-05-06 16:30:23,143 SoftRefFilesCache:130 putFile-&gt; putFile: sftp://[user]:***@[server]/
  DEBUG 2019-05-06 16:30:23,181 SoftRefFilesCache:130 putFile-&gt; putFile: sftp://[user]:***@[server]/TO_HR
  DEBUG 2019-05-06 16:30:23,443 Transporter:220 transportOutbound-&gt; Completed write to remote file [server]/TO_HR/[file].pgp
  INFO  2019-05-06 16:30:23,444 SftpClientFactory$JSchLogger:324 log-&gt; Disconnecting from [server] port 22
  </code></pre>
  
  <p>And this is the generic piece of code we have to perform transfers like this:</p>
  
  <pre class="lang-java prettyprint-override"><code>String safeUri = escapePassword(uriString, events);
  String hostPath = getHostPath(uriString);
  FileSystemManager fsManager = getFileSystemManager();
  try {
      FileSystemOptions opts = getFSOptions();
      FileObject remoteFile = fsManager.resolveFile(safeUri + remoteFilename, opts);
      IOUtils.copy(new FileInputStream(localFile), remoteFile.getContent().getOutputStream());
  catch(IOException ioe) {
      log.error("", ioe);
  } finally {
      close(fsManager);
  }
  </code></pre>
  
  <p>The file is generated and stored on the server successfully, and we can manually transfer the file to the client using the server's <code>sftp</code> command (the server is CentOS 6 so I assume it's OpenSSH) using the same user credentials used by the application.</p>
  
  <p>Any ideas on what might be going wrong?</p>