I want to download a file from an active SSH session. In many cases I probably could just use SFTP, scp
, rsync
et al but there are times where I have elevated permissions on the remote server in a way I cannot use these methods.
If you're struggling to understand what I mean, imagine that you wanted to download something from /root/
or /var/log/auth.log
. Root login is disabled (because we're not idiots). How do you get that file? Copy it out somewhere less protected and then move it? This is clunky. There are also scenarios where the remote path is complex or temporary, or isn't even a path because I want the output of a remote command stored locally. Store remotely, then copy? Clunk!
There are several more clunky ways to achieve versions of these but in an ideal world, I would have something akin to local write access from the remote server, using the existing SSH session as a conduit. Something like (this is just an artist's impression):
$oli@remote: cp /root/cheesecake /local/
And it just appears in my local cwd
. And bidirectional access wouldn't be a bad thing.
It's been eight long years since I asked this question and we've seen a real range of clunk, but it remains a problem that I still struggle with occasionally.
I've refactored the question into something a lot more idealistic. I fully understand that there may not currently be a perfect answer. All past and future efforts towards my ideal are appreciated.
zssh
is probably closest to the zmodem-like workflow you may be remembering.file="/var/log/auth.log"; content="$(base64 $file)"; printf '\e]8;;data:file/plain;base64,'$content'\e\\'$file'\e]8;;\e\\\n'
(configure your os to use chrome to handle "data:" URIs; you will loose the filename here but with a nested approach it should also be possible )