tldr/pages/common/scp.md

29 lines
942 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 {{path/to/local_file}} {{remote_host}}:{{path/to/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/to/remote_file}} {{path/to/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
`scp -r {{path/to/local_dir}} {{remote_host}}:{{path/to/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/to/remote_file}} {{host2}}:{{path/to/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 {{path/to/local_file}} {{remote_username}}@{{remote_host}}:{{path/to/remote_dir}}`
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/private_key}} {{local_file}} {{remote_host}}:{{/path/remote_file}}`