About scp command generator
scp copies files between your computer and a server over SSH.
Examples
- Upload: scp file.txt user@host:/path/
- Download: scp user@host:/path/file.txt .
- Folders need -r.
For big transfers
rsync can resume and only sends changes, so it is better than scp for large or repeated copies.
A worked example
To upload a build folder, run scp -r ./dist [email protected]:/var/www/site/. To download a log, run scp [email protected]:/var/log/app.log ./. The -P option sets the port, and note that it is a capital P, unlike ssh.
Tips
- Use -C to compress files on slow links.
- For repeated syncing, rsync copies only changes.
- Check permissions on the server after uploading.
Troubleshooting
If you see 'Permission denied', check the key, the user name and the folder permissions on the server. If the command hangs, the port may be blocked by a firewall. Add -v for detailed output.
