Piping content through SSH

Thu 08 December 2011

Thanks to http://www.contentwithstyle.co.uk/content/4-ssh-config-tips-for-faster-remote-working/ I can avoid creating files which need to be scp’d: I can pipe the content directly:

local$ cat localfile.txt | ssh remote "cat - >> remotefile.txt"

For this to work, I have already got “remote” set up in my ~/.ssh/config. You can get much more involved in this: see

My favourite example from the last site (execute commands on remote server but save the output to local) is:

ssh user@example.com "mysqldump -u DB_username -pDB_password DB_name | gzip -c" > /local/dir/DB_backup.gz

tags: proxy, ssh, unix, utilities