sftp: upload all files, directories and sub-directories contained in a folder

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

 put -r .

See man sftp.


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/ [email protected]:/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.


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/ [email protected]:/home/b/

Tags:

Sftp

Put