I have used sshfs to locally mount a SFTP server's filesystem. I am trying to copy .gz files from the sshfs mount (/mnt/mysftp/) to /tmp and noticed when the file is large (~10MB+), it will copy over fine (no errors) but I cannot gunzip it without producing errors. What am I missing to use cp or tar to get these files? I have only successfully retrieved and gunzip'd the files via sftp get


cp /mnt/mysft/log1.log.gz /tmp/
gunzip /tmp/log1.log.gz
gzip: /tmp/log1.log.gz: invalid compressed data--format violated

Then I tried to tar it instead of cp

tar cvf - log1.log.gz | tar xvf - -C /tmp/log1/log.gz
tar: log1.log.gz: File shrank by 13274842 bytes; padding with zeros

gunzip /tmp/log1.log.gz
gzip: /tmp/log1.log.gz: unexpected end of file

Only if I sftp and use 'get' then it works

sftp> get log1.log.gz
Fetching /files/log1.log.gz
sftp> exit
gunzip log1.log.gz

EDIT: I just noticed if I use cp it does not always copy the file in its entirety. Original file is 61MB and cp produces a variable file size each time I try (4MB, 61MB, 350K, etc). Now more confused...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.