2013-12-08 08:56:16 +00:00
|
|
|
# scp
|
|
|
|
|
2016-01-16 08:15:50 +00:00
|
|
|
> Secure copy.
|
|
|
|
> Copy files between hosts using Secure Copy Protocol over SSH.
|
2020-12-17 10:16:17 +00:00
|
|
|
> More information: <https://man.openbsd.org/scp>.
|
2013-12-08 08:56:16 +00:00
|
|
|
|
2016-01-16 08:15:50 +00:00
|
|
|
- Copy a local file to a remote host:
|
2014-01-30 14:22:27 +00:00
|
|
|
|
2016-12-19 06:52:07 +00:00
|
|
|
`scp {{path/to/local_file}} {{remote_host}}:{{path/to/remote_file}}`
|
2014-01-30 14:22:27 +00:00
|
|
|
|
2020-12-17 10:16:17 +00:00
|
|
|
- Use a specific port when connecting to the remote host:
|
|
|
|
|
2021-03-06 20:29:14 +00:00
|
|
|
`scp -P {{port}} {{path/to/local_file}} {{remote_host}}:{{path/to/remote_file}}`
|
2020-12-17 10:16:17 +00:00
|
|
|
|
2019-02-11 18:00:49 +00:00
|
|
|
- Copy a file from a remote host to a local directory:
|
2013-12-08 08:56:16 +00:00
|
|
|
|
2019-02-11 18:00:49 +00:00
|
|
|
`scp {{remote_host}}:{{path/to/remote_file}} {{path/to/local_directory}}`
|
2014-01-30 14:22:27 +00:00
|
|
|
|
2017-04-18 14:07:46 +01:00
|
|
|
- Recursively copy the contents of a directory from a remote host to a local directory:
|
2014-01-30 14:22:27 +00:00
|
|
|
|
2019-02-08 00:28:43 +00:00
|
|
|
`scp -r {{remote_host}}:{{path/to/remote_directory}} {{path/to/local_directory}}`
|
2013-12-08 08:56:16 +00:00
|
|
|
|
2016-01-16 08:15:50 +00:00
|
|
|
- Copy a file between two remote hosts transferring through the local host:
|
2013-12-08 08:56:16 +00:00
|
|
|
|
2019-02-11 18:00:49 +00:00
|
|
|
`scp -3 {{host1}}:{{path/to/remote_file}} {{host2}}:{{path/to/remote_directory}}`
|
2014-01-30 14:22:27 +00:00
|
|
|
|
2016-01-16 08:15:50 +00:00
|
|
|
- Use a specific username when connecting to the remote host:
|
2014-01-30 14:22:27 +00:00
|
|
|
|
2019-02-11 18:00:49 +00:00
|
|
|
`scp {{path/to/local_file}} {{remote_username}}@{{remote_host}}:{{path/to/remote_directory}}`
|
2015-12-25 08:25:01 +00:00
|
|
|
|
2016-01-16 08:15:50 +00:00
|
|
|
- Use a specific ssh private key for authentication with the remote host:
|
2015-12-25 08:25:01 +00:00
|
|
|
|
2023-11-25 07:00:05 +00:00
|
|
|
`scp -i {{~/.ssh/private_key}} {{path/to/local_file}} {{remote_host}}:{{path/to/remote_file}}`
|
|
|
|
|
|
|
|
- Use a specific proxy when connecting to the remote host:
|
|
|
|
|
|
|
|
`scp -J {{proxy_username}}@{{proxy_host}} {{path/to/local_file}} {{remote_host}}:{{path/to/remote_file}}`
|