While SSH’d into a remote machine, I find that I need to grab a file to use it locally. But, I’m behind a firewall … and so is the server, which means I can’t scp the file to or from my machine. I resort to temporarily dropping the file on an intermediate machine accessible by both.
After doing this for a while I ended up with a lot of junk piled on the intermediate machine because I never clean up files after copying them to my lappie.
Using a recently discovered rsync option, --remove-source-files
, I created an alias which does the cleanup for me:
alias grabrm='rsync --remove-source-files'
I now after copying the file to the intermediate machine:
remote_machine$ scp foo.txt intermediate:
I run the following command, which copies the file and removes it from the intermediate machine:
local_machine$ grabrm intermediate:foo.txt .