You are so close!
Don't use backticks, just encapsulate your request in single quotes like this:
ssh foo@bar 'ls -la' |grep baz > out.txt
When in doubt, the -v option is your friend. Doing something like
ssh -v foo@bar `ifconfig en0`
will show you exactly what command you're sending to the server, which in this case would be the output of ifconfig on your local machine