tldr/pages/common/scp.md

34 lines
1.1 KiB
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.
2020-12-17 10:16:17 +00:00
> More information: <https://man.openbsd.org/scp>.
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
2020-12-17 10:16:17 +00:00
- Use a specific port when connecting to the remote host:
`scp {{path/to/local_file}} -P {{port}} {{remote_host}}:{{path/to/remote_file}}`
- Copy a file from a remote host to a local directory:
2013-12-08 08:56:16 +00:00
`scp {{remote_host}}:{{path/to/remote_file}} {{path/to/local_directory}}`
2014-01-30 14:22:27 +00:00
- Recursively copy the contents of a directory from a remote host to a local directory:
2014-01-30 14:22:27 +00:00
`scp -r {{remote_host}}:{{path/to/remote_directory}} {{path/to/local_directory}}`
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_directory}}`
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_directory}}`
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}}`