SSH Piping between remote servers

Posted on Wed 25 January 2012 in misc

SSH is without doubt my favorite command line tool. Today I needed to transfer a file between two hosts that I could SSH to, but could not SSH to each other. This is really simple with a bit of standard UNIX piping.

ssh hostA cat somescript.sh | ssh hostB "cat > somescript.sh"

Job done.

ssh