$ ssh test-vagrant ls
test-dir
$ ssh test-vagrant sh -c "ls ~/test-dir"
test-dir
$ ssh test-vagrant sh -c '"ls ~/test-dir"'
fuga.txt
hoge.txt
strace で何が起こっているのか見てみると、2番目のコマンドでは、
["sh", "-c", "ls", "/home/vagrant/test-dir"]
がリモートで実行されている。
なので、コマンドの部分は、IFS で結合されてリモートのシェルに文字列として system() 実行されているっぽい?