Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

There seem to be a file size limit for sftp transfer from the command line, if I try to download a 20 MB file it stops at 20% when the transfered data is larger than 4 MB:

/myfile.xml                             22% 4480KB 410.4KB/s   00:38 ETA       

Is there a limit somewhere and how can you change it? I use a scripted sftp connection with expect. Downloading the file via Nautilus file manager or sftp from the console without shell script and expect program both seem to work. The script is as follows:

# usage: ./ username host password filepath localpath

set username [lindex $argv 0]
set host [lindex $argv 1]
set password [lindex $argv 2]
set filepath [lindex $argv 3]
set localpath [lindex $argv 4]

spawn sftp $username@$host
expect "password:"
send "$password\r";
expect "sftp>"
send "get $filepath $localpath\r"
expect "sftp>"
send "bye \r";
exit 0
share|improve this question

There is no limit by default (as far as I am aware).

I would guess you are getting packet loss and timing out. I would try adding -P.

-P sftp_server_path Connect directly to a local sftp server (rather than via ssh(1)). This option may be useful in debugging the client and server.


I would probably copy it with rsync, rsync -avrz --ignore-existing /folder/folder/folder

share|improve this answer
up vote 2 down vote accepted

It seems like adding a timeout resolves the problem. The default expect timeout is 10 seconds, which means at a rate of 400 KB/s, the timeout is trigged if 4000 KB = 4 MB is reached

set timeout 300
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.