Data Exfiltration over SSH and SCP
SSH is the cleanest exfiltration channel available on Linux — traffic is encrypted, it blends with legitimate admin activity, and no additional tooling is required beyond the SSH client already present on most systems. If you have SSH credentials or a key and the target can reach your attacker machine on port 22, this is the first method to try.
Stage and compress data before transferring. See Staging and Compressing Data for Exfiltration.
SCP — Single File or Directory
Copy a single file to your attacker machine:
Copy an entire directory recursively:
Copy using a specific private key if password authentication is disabled:
Suppress host key checking when connecting to a new host:
SCP on a Non-Standard Port
If your SSH listener is not on port 22:
Note the capital -P for scp versus lowercase -p for ssh.
SFTP
SFTP gives an interactive session for browsing and transferring multiple files:
Inside the session:
Non-interactive single transfer:
rsync
rsync is useful for large or incremental transfers. It only sends changed blocks, which is faster for repeated exfiltration of an evolving dataset.
-a preserves permissions and timestamps, -v verbose, -z compress in transit.
Over a non-standard SSH port:
Receiving on Your Attacker Machine
Your attacker machine needs SSH running and accepting connections. On Kali this is typically disabled by default — start it first:
Confirm the service is listening:
Make sure the receiving directory is writable by the user being used for the transfer.
Transferring Through a Tunnel
If the target cannot reach your attacker machine directly but you have a reverse SSH tunnel or SOCKS proxy established, route scp through it:
Or through a forwarded port:
Where $LPORT is a locally forwarded port pointing back through the tunnel. See SSH Port Forwarding and Tunneling.
References
-
OpenBSD manual page Full reference for scp options including port, identity file, and proxy usage.
-
OpenBSD manual page Reference for interactive and batch SFTP transfers.
-
Linux man page Full reference for rsync options, remote transfer syntax, and SSH integration.
Was this helpful?
Your feedback helps improve this page.