I have tried to replicate your setup. To this end, I prepared to virtual machines.
First one, let's call it xboard, with xboard
and polyglot
installed, but -while not strictly required- not stockfish
, fairymax
or other engines.
Second one, let's call it stockfish, runs a ssh server and does have stockfish installed.
xboard machine is able to connect to stockfish machine via ssh. In this case ssh host
suffices but using the full ssh -p <port> <user>@<host> /usr/games/stockfish
in the command works as well.
The command you provided
xboard -fcp "ssh -p 22 [email protected] /usr/games/stockfish" -fUCI
works perfectly. xboard is started locally and connects to stockfish via ssh.
I would recommend to set up ssh key authentication. OTherwise, when you start xboard you will need to manually input the password on the terminal where you are running xboard (and if you waited too long, the connection could timeout).
The error you are facing I can reproduce if manually killing polyglot. If ssh failed, polyglot is providing an error.
I don't see why it would be failing (maybe your versions aren't able to properly cope with spaces in the parameters=), but since directly playing with stockfish via ssh works I would try running:
polyglot -noini -ec "ssh -p 22 user@host /usr/games/stockfish" -ed . -uci NalimovCache=4 -pg ShowTbHits=true
which is the command that my xboard runs to connect.