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.
|
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
|
|
|
|
2016-01-16 08:15:50 +00:00
|
|
|
- Copy a file from a remote host to a local folder:
|
2013-12-08 08:56:16 +00:00
|
|
|
|
2016-12-19 06:52:07 +00:00
|
|
|
`scp {{remote_host}}:{{path/to/remote_file}} {{path/to/local_dir}}`
|
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
|
|
|
|
2017-04-18 14:07:46 +01:00
|
|
|
`scp -r {{remote_host}}:{{path/to/remote_dir}} {{path/to/local_dir}}`
|
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
|
|
|
|
2016-12-19 06:52:07 +00:00
|
|
|
`scp -3 {{host1}}:{{path/to/remote_file}} {{host2}}:{{path/to/remote_dir}}`
|
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
|
|
|
|
2016-12-19 06:52:07 +00:00
|
|
|
`scp {{path/to/local_file}} {{remote_username}}@{{remote_host}}:{{path/to/remote_dir}}`
|
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
|
|
|
|
2016-12-19 06:52:07 +00:00
|
|
|
`scp -i {{~/.ssh/private_key}} {{local_file}} {{remote_host}}:{{/path/remote_file}}`
|