mtime.sec is not present

skanagasabap picture skanagasabap · Mar 6, 2014 · Viewed 23k times · Source

I am facing a tricky situation here. I have a java based application that tries to scp remote machines to copy certain files. While performing those tasks , I am finding the below error message from the application side.

scp protocol error mtime.sec not present

But when I manually try to scp from the server to endpoint machine, I am able to do it without issues.

The command I am using for manual testing is scp localfile user@hostname:/tmp/

I am not sure of the error message mtime.sec is not present . Does anyone can throw some lights here. I couldn't find useful info from web, Any experts thoughts would help a lot.

As SCP is working normally using manual process, I am not sure there is something wrong with SCP.

Answer

Bao Ho picture Bao Ho · May 10, 2014

I've got the same issue. It worked for me if I scp to ubuntu 12.04. When I did that to ubuntu 14.04, it failed with same message.

I wrote the scp code based on this example http://www.jcraft.com/jsch/examples/ScpTo.java.html. I guess you too.

If I remove the whitespace after the "T" in the following line, it'll work. Change:

command="T "+(_lfile...

to

command="T"+(_lfile...

Either do that or set ptimestamp = false