Skip to content

Instantly share code, notes, and snippets.

@evilchili
Created September 3, 2015 03:45
Show Gist options
  • Save evilchili/53e9a74d6320c7066bb3 to your computer and use it in GitHub Desktop.
Save evilchili/53e9a74d6320c7066bb3 to your computer and use it in GitHub Desktop.
redirect STDIN to a file on the host where your current SSH session originated. put it in your .bashrc!
# Example 1:
# laptop% ssh remotehost
# remotehost% uptime | laptop remote_uptime
# remotehost% exit
# laptop% cat remote_uptime
# 20:41:11 up 9 days, 4:02, 20 users, load average: 0.02, 0.01, 0.00
#
# In other words, it's like starting this:
# laptop% ssh remotehost uptime > remote_uptime
# but from the remote host.
#
function laptop() {
ssh $(echo $SSH_CLIENT|cut -d' ' -f1) "cat - > $1" < <(cat)
}
@evilchili
Copy link
Author

remotehost% laptop remote_motd < /etc/motd

This works too!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment