Questions like How to remotely write to a file using SSH are about a direct SSH.
But I am reaching the end of a reverse tunnel which ends on intermediateserver. That is, I'm ssh'ing to one machine through another. And I want to write to a file on the distant machine. The following fails; it ends up writing on the intermediateserver!
ssh -A -t intermediateserver ssh -A -t -p 666 localhost "echo 30 > tmp"
The fact that there's a reverse ssh tunnel in there probably doesn't make things more complicated, so more generally, I am sitting on homeserver and going through intermediateserver to distantserver.
(In my case here, distant server appears to intermediate server internally on its port 666, due to a preexisting reverse tunnel) .