SSH quoting
I tend to do like this  ssh $server "echo $(cat script|base64 -w0) | base64 -d | bash"

No scp, no quoting hell. Obviously there is other ways of doing it. And also if you run it with the base64 printed out it's possible to pass along and the user can still see what will be run.I got good enough on escaping to really give up on it, the worst cases are just not worth the effort.