3 ms·
Would this make it through the SSH gateway? It creates a pseudo TTY and executes bash as a login shell within it. ssh hostname -qt 'bash -lc "tar czf - /path
by tssva 6y ago
Would this make it through the SSH gateway? It creates a pseudo TTY and executes bash as a login shell within it.
ssh hostname -qt 'bash -lc "tar czf - /path/to/folder 2>/dev/null | base64"' | base64 -id | tar xvzf -
- wahern 6y agoProbably want to prepend a prefix so you can extract only those lines and filter banners, motd's, etc, like: "... base64 | sed -e 's/^/~/'" | sed -ne 's/^~//p' | base64 ...` BTW, base64 isn't a standard command (nonexistent on OpenBSD), and the options can vary based on implementation even when it exists (decode is -d for GNU coreutils base64, but -D for the macOS command). You can whip up an alternative using od(1) and printf(1): #!/bin/sh # encode as backslash-escaped octal (\0NNN) export LC_ALL=C od -An -to1 -v \ | sed -ne 's/\([01234567][01234567]*\)/\\0\1/gp' \ | tr -cd '\\01234567\n' #!/bin/sh # decode backslash-escaped octal export LC_ALL=C while read -r L; do printf "%b" "$L" done It might not be strictly POSIX compliant, but I don't think there are any environments where printf isn't 8-bit clean in the C locale. I've tested something similar (see below) on various versions of bash and d?ash, as well as /bin/sh on AIX, FreeBSD, macOS, OpenBSD, NetBSD, and Solaris. You can implement base64 as a shell script using the above techniques, and do so without relying on awk, which isn't always available. If od(1) isn't available you can use dd(1) to extract stdin byte-by-byte and convert with printf(1), but that gets really slow. I've written an implementation that only needs an 8-bit-clean but otherwise POSIX compliant shell, printf, and either dd or od. It doesn't need tr, but it's even slower without it. It just converts the bytes to decimal and uses plain shell arithmetic for the primitive encoding and decoding, similar to how it would be done in any language.
- tssva 6y agoIt certainly isn't a complete cross platform solution but to address the inconsistent options problem and some of the availability issues openssl could be used instead. ... | openssl enc -base64" | openssl -base64 -d | ...
- tssva 6y agoSelf reply. Noticed I left out the enc option from the 2nd openssl command. Should be: ... | openssl enc -base64" | openssl enc -base64 -d | ...