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

From a directory of dozens of files, is it possible to GET or PUT two files at once using SFTP?

I do not want to use a wildcard because I don't necessarily know the names of all the files and don't want to affect other files.

I'm hoping there's something like:


From Google searching and looking on various Stackexchanges, it doesn't look like this is possible.

Does anyone know for sure?

share|improve this question
up vote 3 down vote accepted

you can do:

sftp user@host << EOF!
get /path/to/file1
get /path/to/file2

But personally I prefer to use scp in such cases.

share|improve this answer

If possible, use lftp as your sftp client (available for all the relevant Linux distros and *BSDs in their package collections):

lftp s

Then you can use mgetcommand:

mget stylesheet.css

If lftp is not possible to use, then you can use -b (batch) option in standard sftp command. First create a text file containing

get stylesheet.css

And then use command

sftp -b yourtextfile.txt
share|improve this answer

You can't do this with sftp, the syntax for get is get remote-path [local-path] which means that the second parameter if supplied will be used to rename the file on the local system. Similarly put would rename the uploaded file if a second parameter is supplied.

You could use scp to to the job

scp user@remote.tld:"/path/to/ /path/to/stylesheet.css" /local/path

You could also use an sftp script.

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.