Is it possible to access cardano-node on remote server from cardano-cli?

Would love to have some example of connecting cardano-cli to cardano-node that is running on a separate machine. I bet it can be done via SSH. did anyone try to do it?

Yes, you can forward the socket through an SSH tunnel. It’s easiest from Linux to Linux, but other combinations of operating systems might be possible. The following will forward the socket /tmp/forwarded.socket on the local machine to the socket /remotedir/cardano-node/state-node-mainnet/node.socket on remotemachine.

ssh -nNT -L /tmp/forwarded.socket:/remotedir/cardano-node/state-node-mainnet/node.socket remotemachine

Reverse tunneling is also possible.