Linux tricks, one-liners & shell magic

#!/bin/vpp.dk

Community Linux tricks, one-liners & shell scripts — searchable & formatted.

Category: ssh-remote — 2 trick(s)

+ Add a New Trick

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/
Delete this trick? This cannot be undone.
Access a service running on a remote server as if it were local. Useful for databases, dev servers, etc.
bash
$ # Forward remote port 5432 to local port 5432: ssh -L 5432:localhost:5432 user@remote-host # Persistent background tunnel (no shell): ssh -fNL 8080:localhost:80 user@remote-host
Delete this trick? This cannot be undone.