Skip to content

Instantly share code, notes, and snippets.

@yath

yath/sssh

Last active Aug 29, 2015
Embed
What would you like to do?
sssh - sane(r) ssh
#!/bin/sh
# sssh - sane(r) ssh
#
# executes a remote command (more) sanely by passing the arguments url-like
# escaped (foo%23bar for "foo#bar") and unpacking them on the remote side
# with perl again.
if [ "$#" -lt 2 ]; then
echo "Usage: $0 <host> <command> [arguments...]" >&2
exit 1
fi
host="$1"; shift
exec ssh "$host" "perl -le 's/%(..)/chr hex \$1/ge for @ARGV; exec { \$ARGV[0] } @ARGV or die \$!.\$/' --" \
$(perl -le 'for (@ARGV) { s/[^A-Za-z0-9,.-]/sprintf("%%%02x", ord $&)/ge; print }' -- "$@")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.