Last active
November 23, 2023 15:06
-
-
Save rubinchyk/ec98b05d1704da382bc9458afa7db523 to your computer and use it in GitHub Desktop.
SCP cheatsheet (Uploading/Downloading files)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
**Upload a file to a remote server:** | |
```sh | |
scp /path/to/local/file username@remotehost:/path/to/remote/directory | |
``` | |
**Download a file from a remote server:** | |
```sh | |
scp username@remotehost:/path/to/remote/file /path/to/local/directory | |
``` | |
**Copy a directory to a remote server:** | |
```sh | |
scp -r /path/to/local/folder username@remotehost:/path/to/remote/directory | |
``` | |
**Download a directory from a remote server:** | |
```sh | |
scp -r username@remotehost:/path/to/remote/folder /path/to/local/directory | |
``` | |
**Use a non-standard SSH port (e.g., 2222):** | |
```sh | |
scp -P 2222 /path/to/local/file username@remotehost:/path/to/remote/directory | |
``` | |
**Preserve file timestamps and permissions:** | |
```sh | |
scp -p /path/to/local/file username@remotehost:/path/to/remote/directory | |
``` | |
**Quiet mode (suppress progress meter and non-error messages):** | |
```sh | |
scp -q /path/to/local/file username@remotehost:/path/to/remote/directory | |
``` | |
**Enable compression:** | |
```sh | |
scp -C /path/to/local/file username@remotehost:/path/to/remote/directory | |
``` | |
Remember to replace `/path/to/local/file` and `/path/to/local/folder` with the path to your local file or folder, `username` with your username on the remote server, `remotehost` with the IP address or domain name of the remote server, and `/path/to/remote/directory` or `/path/to/remote/folder` with the target path on the remote server. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment