34

On machine A I have the folder

/home/a/

On machine B I have the folder

/home/b/

I wish transfer all files, directories and sub-directories of /home/a in /home/b with sftp On machine A I tried the commands:

sftp fibon82@machineB.com
put /home/a/* /home/b/

but it doesn't work, i get the error message: "skipping non-regular file /home/a/a1"... [a1 is a sub-directory of a]
How could I modify the put instruction?

Thanks! :)

EDIT:

I solved using scp:

scp -r /home/a/ fibon82@machineB.com:/home/b/
fibon82
  • 343

6 Answers6

34

In sftp this command recursively uploads content of the current directory to the remote current directory:

 put -r .

See man sftp.

26

Although not strictly equivalent to sftp, rsync is a very powerful alternative for scp and sftp, especially when updating the copies from machine A to machine B, as it doesn't copy the files that haven't been altered; it's also able to remove files from machine B that have been deleted from machine A (only when it's told to of course).

In your case, the syntax would be

rsync -zrp /home/a/ user@remote.host.com:/home/b/

The -r option is for recursively copying files, -z enables compression during the transfer, and -p preserves the file permissions (file creation, edit, etc.) when copying, which is something that scp doesn't do AFAIK. Many more options are possible; as usual, read the man pages.

Karolos
  • 2,664
11

scp (secure copy) is the Linux de facto for transferring files over a secure tunnel. In your case you would want to use the recursive switch, e.g.:

scp -r /home/a/ user@remote.host.com:/home/b/
deed02392
  • 3,132
  • 6
  • 30
  • 36
4

Try using

put -r /home/a/ /home/b/

for more info check out: this

0

Actually, put -r should work. But the destintion folder needs to be present on your remote host:

sftp> put -r sourcefolder
 Uploading sourcefolder/ to /user/folder
 Couldn't canonicalize: No such file or directory
 ....
sftp> mkdir sourcefolder
sftp> put -r sourcefolder
 Uploading sourcefolder/ to /user/folder/sourcefolder
 Entering sourcefolder/
 sourcefolder/file1
 sourcefolder/file2
Dieter
  • 1
-1

In my case rsync wasn't possible so I used:

mput -rp /home/a/ /home/b/
jayarjo
  • 139