I had a problem when using Chessbase to connect to a remote server. What I wanted to do was run a remote engine command using SSH. However, Chessbase needs a .exe file to act as an engine, so I needed something that I could use to trick Chessbase into thinking I have an engine locally, when it is really on a remote server.
Overview
Chessbase usually works like this:
Basically I want something like this:
That connection between Chessbase locally and Stockfish running on a different server is what I need to set up. What I need is a .exe program on my Windows laptop that Chessbase recognizes as a UCI engine, but behind the scenes is handling the connection to the remote server and sending all the engine commands there.
InBetween - The Current (not great) Solution
What most people seem to do here is use a piece of software called InBetween. It is a little bit of a mysterious piece of software. I think the official version is at polarchess.net. The web is full of broken links and shared InBetween.zip
files of different versions. I also started an archive of InBetween versions.
InBetween mostly does what I wanted to do. I could configure it to run an arbitrary command and then use that as a proxy to my remote chess engine.
But there are some downsides. First, I could not get it to work with the standard OpenSSH software that comes with Windows 10. Instead, I only could get it to work with PuTTY (an older SSH client). Because I had to use PuTTY, I had to do some weird things like converting standard private keys to a PuTTY-specific format.
The other problem I had was trying to connect to servers that changed IP addresses. When this happens, you first have to verify you know the host before you can connect. Or, if you are really sure you trust the host, you can skip this step. But this was another problem with PuTTY and InBetween.
Creating an Alternative
Here were my goals:
- Use standard SSH to connect to a remote server that has stockfish (or other) engine on it
- Have a configuration file (similar to InBetween) so I can change the connection options easily, especially the host address
- Do not need to use PuTTY or convert my standard SSH keys
- Be able to run the program (from different directories) for different connections
Enter Go. Go is a programming language with the benefit of being able to compile code into executables that run on many different systems, including Windows. My idea was to build a simple program that reads a configuration file and then acts as a chess engine. It also has built-in SSH libraries so the resulting source code is fairly short and easy.
Introducting SSH Engine
The result is a program I called SSH Engine. The source code is free and open and can be found here on GitLab. It works on Windows, but also works on other systems like MacOS or Linux. Though on those other systems it might be just as easy to create a shell script that calls SSH so my focus is on Windows.
Currently there are some early releases that you can download here. The current state is: It works but needs a tune up. I have been using it to connect to a remote cloud-based server, local raspberry pi cluster, and a local server that just runs Stockfish.
Using SSH Engine
Basically you just need to save the .exe file to your Windows computer.
SshEngine basically works the same as if you were to use a command like:
ssh -i C:\Users\matt\.ssh\stockfish-keypair.pem ubuntu@11.222.33.444 stockfish
Instead you move all the command-line parameters to an engine.yml
file that looks like this:
user: "ubuntu"
privateKeyFile: "C:\\Users\\matt\\.ssh\\stockfish-keypair.pem"
host: "11.222.33.444"
port: "22"
remoteCommand: "stockfish"
The engine.yml
file must be in the same directory as the SshEngine.exe
file. The latest format of that file can be found here.
This is to connect to a cloud-based server (see my posts on cloud engines). To connect to a raspberry pi your file might look more like this:
user: "matt"
privateKeyFile: "C:\\Users\\matt\\.ssh\\id_rsa"
host: "192.168.1.100"
port: "22"
remoteCommand: "/home/pi/stockfish"
You can test that everything is working by running SshEngine.exe
. A window should appear and you should be connected to your remote server and stockfish
should be running. If that does not work, you can try running SshEngine.exe
from a command prompt/terminal to see what error messages show up.
Connecting with Chessbase
Once it is set up you just point your chess software to the SSHEngine.exe
file and it should connect to your remote server. Chessbase does not realize (or care) that it is running an engine on a different computer.
To see how I automatically configure this to connect to a cloud-based engine, you can read about how I use a remote engine. I also used this for my cloud-based supercomputer.
One Technical Thought
In theory, this program should work for any remote command over SSH. However, I did have to add one check that ties it to UCI chess engines. That is having it listen for quit
to end the program, which is how UCI engines signal the end of execution. If I didn’t need that piece, this could be used as a proxy to any command. But, since I’m focused on chess engines, I will let it have this check for now.
Feedback?
Have you tried it and it doesn’t work? Want to request a feature? Please create an issue