tldr/pages/common/scp.md

29 lines
905 B
Markdown
Raw Normal View History

2013-12-08 08:56:16 +00:00
# scp
> Secure copy.
> Copy files between hosts using Secure Copy Protocol over SSH.
2013-12-08 08:56:16 +00:00
- Copy a local file to a remote host:
2014-01-30 14:22:27 +00:00
`scp {{local_file}} {{remote_host}}:{{/path/remote_file}}`
2014-01-30 14:22:27 +00:00
- Copy a file from a remote host to a local folder:
2013-12-08 08:56:16 +00:00
`scp {{remote_host}}:{{/path/remote_file}} {{/path/local_dir}}`
2014-01-30 14:22:27 +00:00
- Recursively copy the contents of a directory on a remote host to a local directory:
2014-01-30 14:22:27 +00:00
2016-03-19 06:01:04 +00:00
`scp -r {{/path/local_dir}} {{remote_host}}:{{/path/remote_dir}}`
2013-12-08 08:56:16 +00:00
- Copy a file between two remote hosts transferring through the local host:
2013-12-08 08:56:16 +00:00
`scp -3 {{host1}}:{{/path/remote_file.ext}} {{host2}}:{{/path/remote_dir}}`
2014-01-30 14:22:27 +00:00
- Use a specific username when connecting to the remote host:
2014-01-30 14:22:27 +00:00
`scp {{local_file}} {{remote_username}}@{{remote_host}}:{{/remote/path}}`
2015-12-25 08:25:01 +00:00
- Use a specific ssh private key for authentication with the remote host:
2015-12-25 08:25:01 +00:00
`scp -i {{~/.ssh/id_rsa}} {{local_file}} {{remote_host}}:{{/path/remote_file}}`