You can use the put
command with the -r
option for a recursive copy.
put [-Ppr] local-path [remote-path]
Upload local-path and store it on the remote machine. If the remote path name is not specified, it is given the same name it has on the local machine. local-path may contain glob(3) char‐
acters and may match multiple files. If it does and remote-path is specified, then remote-path must specify a directory.
If either the -P or -p flag is specified, then full file permissions and access times are copied too.
If the -r flag is specified then directories will be copied recursively. Note that sftp does not follow symbolic links when performing recursive transfers.
Interactive mode
$ sftp my.server.com
Connected to my.server.com.
sftp> put -r /home/whoever/files_to_send /some/remote/directory
Single command for cron runs
$ cat batchfile
put -r /home/whoever/files_to_send /some/remote/directory
$ sftp -b batchfile my.server.com
What you should really learn from this is to read the online manual, sftp(1)
.