Linux tricks, one-liners & shell magic
← Back to all tricks
Copy files over SSH (scp)

Securely transfer files between machines using scp. Works in both directions — local to remote and remote to local.

bash
$ # Local -> Remote scp localfile.txt user@host:/remote/path/ # Remote -> Local scp user@host:/remote/file.txt ./ # Recursive directory copy: scp -r ./mydir user@host:/opt/
shellwitch2026-04-19
Delete this trick? This cannot be undone.