Sign up ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It's 100% free, no registration required.

When I try to use sftp to transfer a directory containing files, I get an error message:

skipping non-regular file directory_name

The directory contains a couple of files and two subdirectories.

What am I doing wrong?

share|improve this question

5 Answers 5

up vote 10 down vote accepted

sftp, like cp and scp, requires that when you copy a folder (and its contents, obviously), you have to explicitly tell it you want to transfer the folder recursively with the -r option.

So, add -r to the command.

share|improve this answer
-r after the put command? I am getting a "put: Invalid flag -r" error message message if I do. Adding it to the original sftp command also does not work. – haziz Dec 17 '11 at 9:12
Add -r to the sftp command when you're connecting. sftp -r user@host – Kevin Dec 17 '11 at 15:50
@Kevin I am getting the following error "sftp: unknown option --r" – Amatya Mar 27 '14 at 20:06
It looks like the -r option was added to OpenSSH sftp version 4.7. Go here and you can use the form at the top to see different versions of the man page. – Kenster Oct 2 '14 at 20:55

I can only suggest, you use rsync. It is somewhat of an industry standard, when moving files over secure connections.

rsync -alPvz ./source_dir

It is what I've been using for years by now.

(the -a option takes care of things like directory recursion)

share|improve this answer

If you can, use sshfs. It's a FUSE filesystem, available on most modern unices, and works with any SFTP server. This is a remote filesystem: it allows you to manipulate remote files (over the SFTP protocol) with the usual utilities.

mkdir /mount/point
sshfs /mount/point
ls /mount/point
cp -Rp /mount/point/somedir /local/location
fusemount -d /mount/point
share|improve this answer

If rsync is not an option, I would next recommend lftp:

lftp s

Then use the mirror command to recursively upload, like this:

mirror -R

(Note that recursion is the default. The -R is for reverse — to make the mirror command upload instead of download. Try adding --dry-run to do a trial to make sure it's doing what you expect.)

Or to upload without recursion:

mirror --no-recursion

You have to cd into the directories you want to mirror. Works great!

share|improve this answer

This works for me:

1) connect via sftp to remote host

2) change into the remote directory you wish to copy. (Example: cd Music)

3) change to the local directory you wish to copy stuff to. (Example: lcd Desktop)

4) Issue this command: get -r *

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.