Skip to contents

Upload and download files to/from the SSH server via the scp protocol. Directories in the files argument are automatically traversed and uploaded / downloaded recursively.


scp_download(session, files, to = ".", verbose = TRUE)

scp_upload(session, files, to = ".", verbose = TRUE)



ssh connection created with ssh_connect()


path to files or directory to transfer


existing directory on the destination where files will be copied into


print progress while copying files


Note that the syntax is slightly different from the scp command line tool because the to parameter is always a target directory where all files will be copied into. If to does not exist, it will be created.

The files parameter in scp_upload() is vectorised hence all files and directories will be recursively uploaded into the to directory. For scp_download() the files parameter must be a single string which may contain wildcards.

The default path to = "." means that files get downloaded to the current working directory and uploaded to the user home directory on the server.

See also


if (FALSE) {
# recursively upload files and directories
session <- ssh_connect("")
files <- c(R.home("doc"), R.home("COPYING"))
scp_upload(session, files, to = "~/target")

# download it back
scp_download(session, "~/target/*", to = tempdir())

# delete it from the server
ssh_exec_wait(session, command = "rm -Rf ~/target")