Urgent.News

What's breaking now, across thousands of outlets.

Tech

Notes on the tar + ssh pipe technique

I can never quite recall the exact command when I actually need it, so I'm parking it here for copy-paste. TL;DR (for the impatient) # Pull from remote to local (with sudo) ssh host "sudo tar cz /var/log/nginx" | tar xzv --strip-components = 3 # Push from local to remote tar cz . | ssh host "tar xz -C /path/to/dest" What happened I needed to pull logs off an old CentOS server. Tried rsync: -bash:…

The tar + ssh pipe technique provides a versatile solution for transferring files when rsync or scp are not available. To pull files from a remote server, the syntax is ssh host sudo tar cz /path/to/dir | tar xz. For pushing files to a remote server, use tar cz . | ssh host tar xz -C /path/to/dest. This method compresses files on the fly to save bandwidth and avoids creating temporary files on the remote machine.

When using sudo, the command ssh host sudo tar cz /var/log/nginx | tar xzv --strip-components=3 extracts the files without leaving a temp file on the remote server. The --strip-components flag removes the first three path components, resulting in the files being extracted as nginx/. The extraction target can be chosen by specifying the destination with -C on the extracting side of the pipe.

Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.

Read the original at dev.to →

More in Tech

How ECHOS discloses a vulnerability

ECHOS is the research program at Stonepath IT. It looks for vulnerabilities in other people's software, and its focus is self-hosted MCP servers and agent infrastructure.

More from Thursday 15 October →