{"id":56,"date":"2025-01-20T21:00:00","date_gmt":"2025-01-20T21:00:00","guid":{"rendered":"https:\/\/blog.chessboardmagic.com\/?p=56"},"modified":"2025-09-28T21:56:10","modified_gmt":"2025-09-28T21:56:10","slug":"creating-your-own-stockfish-in-the-cloud","status":"publish","type":"post","link":"https:\/\/blog.chessboardmagic.com\/index.php\/2025\/01\/20\/creating-your-own-stockfish-in-the-cloud\/","title":{"rendered":"Creating Your Own Stockfish in the Cloud"},"content":{"rendered":"\n<p><strong>Setting up Stockfish in the cloud can be a game-changer for chess enthusiasts and professionals alike. By leveraging the power of cloud computing, you can access high-performance chess analysis from any device, even if your personal laptop or desktop is underpowered. Whether you want faster calculations, the ability to run multiple analysis sessions, or just the convenience of a persistent remote setup, the cloud offers an ideal solution.<\/strong><\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<h3 class=\"wp-block-heading\"><strong>IMPORTANT<\/strong><\/h3>\n\n\n\n<p>I just received word that Digital Ocean charges for CPU and RAM even though the service is switched off, as such, I will be adjusting this guild to use a different cloud provider, the steps should almost be identical. Amazon AWS, Google, Microsoft Azure who do charge if your platform is not running, but a minimal amount for storage. If you have followed this guide, please tear down your Droplets immediately to avoid costs and raise a ticket to complain about this, as it is not how most cloud computing organisations work. My sincerest apologies. I did not read the fine print and assumed that this was like most cloud platforms<\/p>\n<\/blockquote>\n\n\n\n<p>Recently,&nbsp;<strong>IM David Shahinyan<\/strong>&nbsp;reached out to me with a simple yet intriguing question: \u201cHave you ever set up Stockfish in the cloud?\u201d I hadn\u2019t, but the idea immediately sparked my interest. It made perfect sense\u2014cloud computing could provide unmatched power and flexibility for chess analysis, especially for those with hardware limitations. Inspired by his question, I decided to give it a shot.<br>At first, I turned to online guides, hoping to find a straightforward solution. Unfortunately, most of the guides I came across were either too complex, incomplete, or didn\u2019t quite work for me. After several failed attempts to get them fully working, I realized the best way forward was to start from scratch. I wanted to create a method that worked reliably and, just as importantly, document it in a clear and accessible guide to help others avoid the same frustrations I faced.<br>This guide is designed specifically for Windows users. Along the way, we\u2019ll install a few key pieces of software, do some light programming, and tackle the entire process step by step. I\u2019ll include as much detail as possible to ensure you can follow along, whether you\u2019re tech-savvy or completely new to cloud computing. By the end, you\u2019ll have a fully functional cloud-based Stockfish setup\u2014and hopefully learn a few new skills in the process! Let\u2019s dive in and make this journey a success.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><a href=\"https:\/\/lichess.org\/@\/HollowLeaf\/blog\/creating-your-own-stockfish-in-the-cloud\/uzjL07Hf#1-putty\"><\/a>1. PuTTY<\/h2>\n\n\n\n<p>PuTTY is a free tool that helps you connect to other computers over the internet. Think of it as a remote control for a computer that\u2019s far away\u2014in this case, our cloud server. We\u2019ll use PuTTY to securely log into the server, send commands, and manage it from your own computer.<br>PuTTY also includes some helpful tools, like PuTTYgen, which we\u2019ll use to create special keys that act like passwords but are more secure. These keys will help ensure that only you can access your server.<br>In this guide, PuTTY will help us:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>Connect to the Cloud Server<\/strong>: It allows us to log in to our cloud server and control it remotely.<\/li>\n\n\n\n<li><strong>Generate Security Keys<\/strong>: PuTTYgen, one of its tools, lets us create a secure way to access the server without needing to type a password every time.<\/li>\n<\/ol>\n\n\n\n<h4 class=\"wp-block-heading\"><a href=\"https:\/\/lichess.org\/@\/HollowLeaf\/blog\/creating-your-own-stockfish-in-the-cloud\/uzjL07Hf#steps-to-install-putty\"><\/a><strong>Steps to Install PuTTY<\/strong><\/h4>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>Download PuTTY<\/strong>:\n<ul class=\"wp-block-list\">\n<li>Go to the official PuTTY website:\u00a0<a href=\"https:\/\/www.putty.org\/\">https:\/\/www.putty.org<\/a>.<\/li>\n\n\n\n<li>Download the\u00a0<strong>PuTTY installer<\/strong>\u00a0for Windows. If you\u2019re not sure which version to pick, choose the 64-bit version, as most modern computers support it.<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>Install PuTTY<\/strong>:\n<ul class=\"wp-block-list\">\n<li>Double-click the downloaded file and follow the instructions to install PuTTY.<\/li>\n\n\n\n<li>Make sure you include\u00a0<strong>PuTTYgen<\/strong>\u00a0during the installation (it\u2019s usually selected by default).<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>Generate Your Public and Private Keys<\/strong>:\n<ul class=\"wp-block-list\">\n<li>Open\u00a0<strong>PuTTYgen<\/strong>\u00a0(it will be listed in your Start menu or desktop after installation).<\/li>\n\n\n\n<li>Click\u00a0<strong>Generate<\/strong>, and move your mouse around the empty area to create randomness for the keys.<\/li>\n\n\n\n<li>Once the keys are created:\n<ul class=\"wp-block-list\">\n<li>Save the\u00a0<strong>private key<\/strong>\u00a0to your computer in a safe place. Name it something like\u00a0<code>private.key.ppk<\/code>\u00a0and keep it secure.<\/li>\n\n\n\n<li>Save the\u00a0<strong>public key<\/strong>\u00a0as a separate file, such as\u00a0<code>public.key.pub<\/code>, in the same folder.<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li>(Optional) You can set a passphrase for your private key. This adds an extra layer of protection if someone gains access to your private key file.<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p><strong>What Are Private and Public Keys, and Why Are They Important?<\/strong><br>Private and public keys are like a special pair of digital locks and keys that work together to secure your connection to a server. The&nbsp;<strong>private key<\/strong>&nbsp;is your secret key, which you must keep safe and never share with anyone. It\u2019s like a master key that allows you to unlock access to your server. The&nbsp;<strong>public key<\/strong>, on the other hand, is meant to be shared. It\u2019s like a lock you give to the server, which can only be unlocked by your private key.<br>This method of security, called&nbsp;<strong>public-key cryptography<\/strong>, ensures that only someone with the matching private key (you) can access the server. It\u2019s much safer than a traditional password because even if someone intercepts the public key, they cannot guess the private key. By using this system, you can protect your server from unauthorized access and ensure a secure, encrypted connection for managing it remotely.<\/p>\n<\/blockquote>\n\n\n\n<p>That\u2019s it! You\u2019ve installed PuTTY and prepared your security keys, which we\u2019ll use to access the cloud server in the next step.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><a href=\"https:\/\/lichess.org\/@\/HollowLeaf\/blog\/creating-your-own-stockfish-in-the-cloud\/uzjL07Hf#2-setting-up-your-server\"><\/a>2. Setting Up Your Server<\/h2>\n\n\n\n<p>A cloud platform is like renting a powerful computer that lives on the internet. It allows you to run programs and store data without relying on your own hardware. For this guide, we\u2019ll use&nbsp;<strong>DigitalOcean<\/strong>, a popular cloud service that is beginner-friendly, cost-effective, and provides all the features we need to set up Stockfish.<br>With DigitalOcean, you can create a virtual server (called a \u201cdroplet\u201d) that runs 24\/7 and is powerful enough to handle complex chess calculations. You also have the flexibility to&nbsp;<strong>switch the droplet on and off<\/strong>&nbsp;as needed, saving costs when it\u2019s not in use.<br><strong>Why DigitalOcean?<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Ease of Use: Its interface is simple and intuitive, making it a great choice for first-time users.<\/li>\n\n\n\n<li>Affordable Pricing: You can start with a droplet for as little as $6\/month.<\/li>\n\n\n\n<li>Performance: A server with 4GB of RAM is sufficient for Chessbase and Stockfish.<\/li>\n<\/ul>\n\n\n\n<p>If you\u2019d like to explore alternatives, here are some other widely used cloud platforms:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Amazon Web Services (AWS)<\/strong>: Offers a free tier but has a steeper learning curve.<\/li>\n\n\n\n<li><strong>Google Cloud Platform (GCP)<\/strong>: A flexible and scalable option with a free trial.<\/li>\n\n\n\n<li><strong>Microsoft Azure<\/strong>: Great for integration with other Microsoft products but more enterprise-focused.<\/li>\n<\/ul>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<h4 class=\"wp-block-heading\"><a href=\"https:\/\/lichess.org\/@\/HollowLeaf\/blog\/creating-your-own-stockfish-in-the-cloud\/uzjL07Hf#important-note\"><\/a><strong>Important Note<\/strong><\/h4>\n\n\n\n<p>Cloud services will charge you while the server is running, even if you\u2019re not actively using it. To avoid unnecessary costs, make sure to switch off the server when you don\u2019t need it. Forgetting to turn it off can lead to unexpected charges. Additionally, when selecting a droplet size, you\u2019ll see both the hourly and monthly costs. Keep this in mind to choose a plan that fits your budget and usage needs<\/p>\n<\/blockquote>\n\n\n\n<h4 class=\"wp-block-heading\"><a href=\"https:\/\/lichess.org\/@\/HollowLeaf\/blog\/creating-your-own-stockfish-in-the-cloud\/uzjL07Hf#step-1-sign-up-for-digitalocean\"><\/a><strong>Step 1: Sign Up for DigitalOcean<\/strong><\/h4>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Go to\u00a0<a href=\"https:\/\/www.digitalocean.com\/\">https:\/\/www.digitalocean.com<\/a>\u00a0and create an account.<\/li>\n\n\n\n<li>Provide your billing information and take advantage of the free trial for new users.<\/li>\n<\/ul>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p>If you\u2019d like to support my work, you can use the following affiliate link to sign up for DigitalOcean:&nbsp;<a href=\"https:\/\/m.do.co\/c\/21fa2a3f2212\">https:\/\/m.do.co\/c\/21fa2a3f2212<\/a>. You\u2019ll receive&nbsp;<strong>$200 in free credits<\/strong>, and I\u2019ll earn additional credits as well, which helps me continue creating content like this.<\/p>\n<\/blockquote>\n\n\n\n<h4 class=\"wp-block-heading\"><a href=\"https:\/\/lichess.org\/@\/HollowLeaf\/blog\/creating-your-own-stockfish-in-the-cloud\/uzjL07Hf#step-2-create-a-droplet\"><\/a><strong>Step 2: Create a Droplet<\/strong><\/h4>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Log in to your account and click\u00a0<strong>Create Droplet<\/strong>.<\/li>\n\n\n\n<li>Choose\u00a0<strong>Ubuntu<\/strong>\u00a0as the operating system. This is a stable and popular Linux distribution suitable for running Stockfish.<\/li>\n<\/ul>\n\n\n\n<h4 class=\"wp-block-heading\"><a href=\"https:\/\/lichess.org\/@\/HollowLeaf\/blog\/creating-your-own-stockfish-in-the-cloud\/uzjL07Hf#step-3-configure-the-droplet\"><\/a><strong>Step 3: Configure the Droplet<\/strong><\/h4>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Select a droplet with at least\u00a0<strong>4GB of RAM<\/strong>\u00a0to ensure Stockfish runs smoothly.<\/li>\n\n\n\n<li>Review the hourly and monthly costs to select a plan within your budget.<\/li>\n\n\n\n<li>Choose a data center region closest to your location for better performance. For example, if you&#8217;re in North America, choose New York or San Francisco. If you&#8217;re in Europe, consider Frankfurt or London.<\/li>\n<\/ul>\n\n\n\n<h4 class=\"wp-block-heading\"><a href=\"https:\/\/lichess.org\/@\/HollowLeaf\/blog\/creating-your-own-stockfish-in-the-cloud\/uzjL07Hf#step-4-add-your-public-key\"><\/a><strong>Step 4: Add Your Public Key<\/strong><\/h4>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Select\u00a0<strong>SSH Keys<\/strong>\u00a0under authentication and click\u00a0<strong>New SSH Key<\/strong>.<\/li>\n\n\n\n<li>Open your\u00a0<code>public.key.pub<\/code>\u00a0file in a text editor like Notepad.<\/li>\n\n\n\n<li>Copy only the key content without the\u00a0<code>---- BEGIN SSH2 PUBLIC KEY ----<\/code>\u00a0or\u00a0<code>---- END SSH2 PUBLIC KEY ----<\/code>\u00a0lines.<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code>---- BEGIN SSH2 PUBLIC KEY ----\nComment: \"rsa-key-20250120\"\nAAAAB3NzaC1yc2EAAAADAQABAAABAQC9XA2JVNQrNwVnu2k+O6hnAH6W+93Dr0Q7\np6Z6VM8MUnxAooAyeqsZmGTgfxwzQ5jMMnqXV+pqBjT\/yrQDnFV\/9ubZFO\/okHe+\nckORuqNyEs++iqMFl4yzLAViJ2O6miKVveVJwFcRsueuvidC4\/BNPiFVGyTR7xMW\nBLvaknSzF4i16zAo\/n41h8OFIUuhW+HT4+HWhIKqOqqaqszUPyTe6I8XHxpp18sX\nr75RCwClxPY1o54lfY7BzaTYUEx\/0hS6kLyulZNCB3g+985+tDL+GQHU3P3aJLr5\n7ZOWtzvf9fcv3dlmx7ZERjccX9XIdCcl8JrGWuWrlIgpbDHBoMgT\n---- END SSH2 PUBLIC KEY ----<\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Combine the lines into one continuous string and add\u00a0<code>ssh-rsa<\/code>\u00a0at the beginning of the key, followed by a space. For example:<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code>ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC9XA2JVNQrNwVnu2k+O6hnAH6W+93Dr0Q7p6Z6VM8MUnxAooAyeqsZmGTgfxwzQ5jMMnqXV+pqBjT\/yrQDnFV\/9ubZFO\/okHe+ckORuqNyEs++iqMFl4yzLAViJ2O6miKVveVJwFcRsueuvidC4\/BNPiFVGyTR7xMWBLvaknSzF4i16zAo\/n41h8OFIUuhW+HT4+HWhIKqOqqaqszUPyTe6I8XHxpp18sXr75RCwClxPY1o54lfY7BzaTYUEx\/0hS6kLyulZNCB3g+985+tDL+GQHU3P3aJLr57ZOWtzvf9fcv3dlmx7ZERjccX9XIdCcl8JrGWuWrlIgpbDHBoMgT<\/code><\/pre>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<h4 class=\"wp-block-heading\"><a href=\"https:\/\/lichess.org\/@\/HollowLeaf\/blog\/creating-your-own-stockfish-in-the-cloud\/uzjL07Hf#important-note-1\"><\/a><strong>Important Note<\/strong><\/h4>\n\n\n\n<p>This has to be a single line otherwise you will get a error.<\/p>\n<\/blockquote>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Paste this single-line key into the\u00a0<strong>Ssh Key Content<\/strong>\u00a0box.<\/li>\n\n\n\n<li>Give the key a recognizable name, such as\u00a0<code>MyLaptopKey<\/code>.<\/li>\n<\/ul>\n\n\n\n<h4 class=\"wp-block-heading\"><a href=\"https:\/\/lichess.org\/@\/HollowLeaf\/blog\/creating-your-own-stockfish-in-the-cloud\/uzjL07Hf#step-5-finalize-and-test-the-connection\"><\/a><strong>Step 5: Finalize and Test the Connection<\/strong><\/h4>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Click\u00a0<strong>Create Droplet<\/strong>\u00a0to complete the setup. DigitalOcean will display the droplet&#8217;s\u00a0<strong>IP address<\/strong>\u00a0(something like\u00a0<code>161.35.239.189<\/code>) once it\u2019s ready.<\/li>\n\n\n\n<li>Open\u00a0<strong>PuTTY<\/strong>\u00a0and enter the droplet\u2019s IP address in the\u00a0<strong>Host Name<\/strong>\u00a0field.<\/li>\n\n\n\n<li>Add your private key by navigating to\u00a0<strong>Connection > SSH > Auth<\/strong>\u00a0in PuTTY\u2019s settings and selecting your\u00a0<code>private.key.ppk<\/code>\u00a0file.<\/li>\n\n\n\n<li>Click\u00a0<strong>Open<\/strong>\u00a0to connect to your droplet. Log in as\u00a0<code>root<\/code>\u00a0(the default user). Since you\u2019re using an SSH key, you won\u2019t need a password.<\/li>\n<\/ul>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p><strong>Note:<\/strong>&nbsp;When you connect to your droplet using PuTTY for the first time, you may see a security alert stating, \u201cThe server\u2019s host key is not cached in the registry.\u201d This message is normal and occurs because PuTTY has not seen the server\u2019s key before. Simply click&nbsp;<strong>Accept<\/strong>&nbsp;to proceed. This will cache the server\u2019s key for future connections, ensuring secure and seamless logins.<\/p>\n<\/blockquote>\n\n\n\n<p>In this section, you learned how to set up a DigitalOcean droplet, configure it with the right specifications, and securely connect using an SSH key to prepare for running Stockfish in the cloud.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><a href=\"https:\/\/lichess.org\/@\/HollowLeaf\/blog\/creating-your-own-stockfish-in-the-cloud\/uzjL07Hf#3-installing-stockfish-on-your-ubuntu-server\"><\/a>3. Installing Stockfish on Your Ubuntu Server<\/h2>\n\n\n\n<p>Stockfish is one of the strongest open-source chess engines in the world. By installing it on your cloud server, you can leverage its power for high-performance analysis, regardless of your local machine&#8217;s capabilities.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\"><a href=\"https:\/\/lichess.org\/@\/HollowLeaf\/blog\/creating-your-own-stockfish-in-the-cloud\/uzjL07Hf#step-1-connect-to-your-ubuntu-server\"><\/a><strong>Step 1: Connect to Your Ubuntu Server<\/strong><\/h4>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Open\u00a0<strong>PuTTY<\/strong>\u00a0and enter your droplet&#8217;s\u00a0<strong>IP address<\/strong>\u00a0in the\u00a0<strong>Host Name<\/strong>\u00a0field.<\/li>\n\n\n\n<li>Ensure your private key (<code>private.key.ppk<\/code>) is loaded under\u00a0<strong>Connection > SSH > Auth<\/strong>.<\/li>\n\n\n\n<li>Click\u00a0<strong>Open<\/strong>\u00a0to connect to your server.<\/li>\n\n\n\n<li>Log in as\u00a0<code>root<\/code>\u00a0(the default administrator user). You won\u2019t need to enter a password since you\u2019re using an SSH key.<\/li>\n<\/ul>\n\n\n\n<h4 class=\"wp-block-heading\"><a href=\"https:\/\/lichess.org\/@\/HollowLeaf\/blog\/creating-your-own-stockfish-in-the-cloud\/uzjL07Hf#step-2-update-your-system\"><\/a><strong>Step 2: Update Your System<\/strong><\/h4>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Run the following commands to ensure your server is up-to-date:\u00a0<code>sudo apt update<\/code>\u00a0and then\u00a0<code>sudo apt upgrade -y<\/code><\/li>\n\n\n\n<li>These commands update the list of available packages and install the latest updates for all installed software.<\/li>\n<\/ul>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p><strong>Note:<\/strong>&nbsp;During the installation or update process, you may be prompted with a message about&nbsp;<code>OpenSSH<\/code>&nbsp;configuration changes, asking whether to keep the local version or install the package maintainer&#8217;s version. Select&nbsp;<strong>Keep the local version installed<\/strong>&nbsp;to avoid overwriting any custom SSH configurations you may already have set up. This ensures your existing SSH connection settings remain intact.<\/p>\n<\/blockquote>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p><strong>What is&nbsp;<code>apt<\/code>?<\/strong><br><code>apt<\/code>&nbsp;(Advanced Package Tool) is a command-line tool used in Ubuntu and other Debian-based Linux distributions to manage software packages. It allows you to:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Install software<\/strong>: Download and install applications from official repositories.<\/li>\n\n\n\n<li><strong>Update packages<\/strong>: Ensure installed software is up-to-date with the latest versions.<\/li>\n\n\n\n<li><strong>Remove software<\/strong>: Uninstall packages no longer needed.<\/li>\n\n\n\n<li><strong>Search for packages<\/strong>: Find software available in the repositories.<\/li>\n<\/ul>\n\n\n\n<p>When you use&nbsp;<code>apt<\/code>, it ensures that all dependencies (additional software or libraries needed by the package) are installed automatically, making the process seamless.<br>For example:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><code>sudo apt install stockfish<\/code>\u00a0installs Stockfish.<\/li>\n\n\n\n<li><code>sudo apt update<\/code>\u00a0refreshes the list of available packages.<\/li>\n\n\n\n<li><code>sudo apt upgrade<\/code>\u00a0upgrades all installed software to the latest versions.<\/li>\n<\/ul>\n<\/blockquote>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p><strong>What is&nbsp;<code>sudo<\/code>?<\/strong><br><code>sudo<\/code>&nbsp;stands for&nbsp;<strong>&#8220;superuser do&#8221;<\/strong>&nbsp;and is a command used to run tasks with administrative (root) privileges. Many system-level operations, like installing software or modifying system files, require elevated permissions for security reasons. Using&nbsp;<code>sudo<\/code>&nbsp;ensures that only authorized users can perform these tasks.<br>For example:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><code>apt install stockfish<\/code>\u00a0will fail if run without\u00a0<code>sudo<\/code>, as installing software requires administrative rights.<\/li>\n\n\n\n<li>Adding\u00a0<code>sudo<\/code>\u00a0before the command, as in\u00a0<code>sudo apt install stockfish<\/code>, temporarily grants the necessary permissions to complete the task.<\/li>\n<\/ul>\n<\/blockquote>\n\n\n\n<h4 class=\"wp-block-heading\"><a href=\"https:\/\/lichess.org\/@\/HollowLeaf\/blog\/creating-your-own-stockfish-in-the-cloud\/uzjL07Hf#step-3-install-stockfish\"><\/a><strong>Step 3: Install Stockfish<\/strong><\/h4>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Install Stockfish using the\u00a0<code>apt<\/code>\u00a0package manager:\u00a0<code>sudo apt install stockfish -y<\/code><\/li>\n\n\n\n<li>This will download and install the latest stable version of Stockfish available in Ubuntu&#8217;s repository.<\/li>\n<\/ul>\n\n\n\n<h4 class=\"wp-block-heading\"><a href=\"https:\/\/lichess.org\/@\/HollowLeaf\/blog\/creating-your-own-stockfish-in-the-cloud\/uzjL07Hf#step-4-verify-stockfish-installation\"><\/a><strong>Step 4: Verify Stockfish Installation<\/strong><\/h4>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Check if Stockfish is installed correctly by running:\u00a0<code>stockfish<\/code><\/li>\n\n\n\n<li>If the installation is successful, you\u2019ll see the Stockfish prompt (<code>Stockfish 15.1 by the Stockfish developers<\/code>) appear.<\/li>\n\n\n\n<li>At the Stockfish prompt, you can test the server&#8217;s computational strength by running the\u00a0<code>bench<\/code>\u00a0command, you should see the following:<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code>Total time (ms) : 3892\nNodes searched  : 2593605\nNodes\/second    : 666393<\/code><\/pre>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p>The&nbsp;<code>bench<\/code>&nbsp;command runs a built-in performance benchmark that evaluates the speed of Stockfish on your server. It provides information such as the number of nodes calculated per second (nps), which indicates the server&#8217;s strength for chess analysis.<\/p>\n<\/blockquote>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Review the output to get an idea of how well Stockfish performs on your server. Higher\u00a0<code>nps<\/code>\u00a0values indicate faster analysis capabilities.<\/li>\n\n\n\n<li>Once done, exit Stockfish by typing:\u00a0<code>quit<\/code><\/li>\n<\/ul>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p><strong>Note<\/strong>: The&nbsp;<code>apt<\/code>&nbsp;package manager installs the stable version of Stockfish available in the Ubuntu repository. If you need the latest development version or want to customize Stockfish, you\u2019ll need to build it from source. For most users, the version installed via&nbsp;<code>apt<\/code>&nbsp;will be sufficient.<\/p>\n<\/blockquote>\n\n\n\n<p>With these steps, we have successfully set up a cloud server, installed Stockfish, and configured secure communication via SSH using PuTTY, allowing you to harness the power of a remote chess engine for high-performance analysis.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><a href=\"https:\/\/lichess.org\/@\/HollowLeaf\/blog\/creating-your-own-stockfish-in-the-cloud\/uzjL07Hf#5-creating-a-proxy-to-connect-stockfish-to-chessbase\"><\/a>5. Creating a Proxy to Connect Stockfish to Chessbase<\/h2>\n\n\n\n<p>Chessbase requires an executable (.exe) file to connect to external engines. Since Stockfish runs on your Ubuntu server, a&nbsp;<strong>proxy<\/strong>&nbsp;is needed to bridge Chessbase and Stockfish. The provided Python script leverages&nbsp;<code>plink.exe<\/code>&nbsp;(installed as part of PuTTY) to establish an SSH connection to your server and relay commands between Chessbase and Stockfish.<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p><strong>Note:<\/strong>&nbsp;Before deciding to create my own proxy, I explored tools like&nbsp;<strong>Polyglot<\/strong>&nbsp;and other similar options to bridge Chessbase with Stockfish. However, after spending considerable time trying to make these tools work without success, I decided to build my own proxy from scratch. This approach allowed me to have full control over the setup and functionality, leading to a simpler, more customizable solution.<\/p>\n<\/blockquote>\n\n\n\n<h4 class=\"wp-block-heading\"><a href=\"https:\/\/lichess.org\/@\/HollowLeaf\/blog\/creating-your-own-stockfish-in-the-cloud\/uzjL07Hf#step-1-install-python\"><\/a><strong>Step 1: Install Python<\/strong><\/h4>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>Download Python<\/strong>:\n<ul class=\"wp-block-list\">\n<li>Visit the official Python website:\u00a0<a href=\"https:\/\/www.python.org\/downloads\/\">https:\/\/www.python.org\/downloads\/<\/a>.<\/li>\n\n\n\n<li>Download the latest version for Windows.<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>Run the Installer<\/strong>:\n<ul class=\"wp-block-list\">\n<li>Double-click the downloaded file to start the installation process.<\/li>\n\n\n\n<li>On the first screen, check the box labeled\u00a0<strong>Add Python to PATH<\/strong>\u00a0(this is important to run Python from the command line).<\/li>\n\n\n\n<li>Click\u00a0<strong>Install Now<\/strong>.<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>Verify the Installation<\/strong>:\n<ul class=\"wp-block-list\">\n<li>Open a command prompt and type:\u00a0<code>python --version<\/code><\/li>\n\n\n\n<li>This should display the installed Python version (e.g.,\u00a0<code>Python 3.x.x<\/code>).<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>Install pip<\/strong>\u00a0(if not already installed):\u00a0<code>python -m ensurepip --upgrade<\/code><\/li>\n<\/ol>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p><strong>Python<\/strong>&nbsp;is a versatile and beginner-friendly programming language known for its simplicity, readability, and extensive library support. Widely used in fields like web development, data analysis, machine learning, and automation, Python&#8217;s clean syntax makes it easy to write and test code quickly. Its cross-platform compatibility ensures it runs seamlessly on Windows, macOS, and Linux, making it ideal for projects involving remote servers. With libraries like&nbsp;<code>subprocess<\/code>,&nbsp;<code>threading<\/code>, and&nbsp;<code>logging<\/code>, Python simplifies complex tasks like managing SSH connections and handling parallel processes. Backed by an active community, Python is an excellent choice for automating workflows and bridging systems\u2014like connecting Chessbase to a remote Stockfish instance\u2014making it an indispensable tool for developers of all levels.<\/p>\n<\/blockquote>\n\n\n\n<h4 class=\"wp-block-heading\"><a href=\"https:\/\/lichess.org\/@\/HollowLeaf\/blog\/creating-your-own-stockfish-in-the-cloud\/uzjL07Hf#step-2-create-the-proxy-remote-stockfishpy\"><\/a><strong>Step 2: Create the Proxy (<code>remote_stockfish.py<\/code>)<\/strong><\/h4>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Create a file called named\u00a0<code>remote_stockfish.py<\/code>\u00a0with the following:<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code>import subprocess\nimport threading\nimport sys\nimport os\nimport json\nimport logging\nimport queue\n## Function to set up logging for the application\ndef setup_logging(config):\n    \"\"\"\n    Configure logging for the application, only if logging is enabled in the config.\n\n    Args:\n        config (dict): Configuration dictionary loaded from config.json.\n    \"\"\"\n    if config.get(\"logging_enabled\", False):  # Check if logging is enabled in the configuration\n        logging.basicConfig(\n            filename=\"debug.log\",  # Log file name\n            level=logging.DEBUG,  # Log level (DEBUG includes detailed information)\n            format=\"%(asctime)s - %(levelname)s - %(message)s\"  # Format for log messages\n        )\n        logging.info(\"Logging initialized.\")  # Log that logging has started\n    else:\n## If logging is disabled, suppress all log levels except CRITICAL\n        logging.basicConfig(level=logging.CRITICAL)\n## Function to load configuration from a JSON file\ndef load_config():\n    \"\"\"\n    Load configuration from config.json located in the same directory as the script.\n\n    Returns:\n        dict: Loaded configuration data.\n    \"\"\"\n    config_path = os.path.join(os.path.dirname(sys.argv&#91;0]), \"config.json\")  # Get the config file path\n    try:\n        with open(config_path, \"r\") as file:  # Open the config file\n            return json.load(file)  # Parse JSON and return as a dictionary\n    except FileNotFoundError:\n        logging.error(f\"Configuration file '{config_path}' not found.\")  # Log if the file is missing\n        sys.exit(1)  # Exit the script with an error\n    except json.JSONDecodeError as e:\n        logging.error(f\"Error parsing configuration file: {e}\")  # Log if JSON is malformed\n        sys.exit(1)\n## Function to handle output from Stockfish and log it\ndef handle_output(process, output_queue, terminate_event):\n    \"\"\"\n    Continuously read output from Stockfish (via Plink) and write it to stdout and logs.\n\n    Args:\n        process: The subprocess running Stockfish (via Plink).\n        output_queue: Queue to store output lines for sequential processing.\n        terminate_event: Event to signal when to stop reading output.\n    \"\"\"\n    try:\n        while not terminate_event.is_set():  # Loop until termination signal is received\n            output = process.stdout.readline()  # Read a line from Stockfish's stdout\n            if not output:  # Stop if no output is received\n                break\n            output = output.strip()  # Remove extra whitespace from the output\n            logging.debug(f\"Stockfish output: {output}\")  # Log the output\n            output_queue.put(output)  # Add the output to the queue for processing\n            sys.stdout.write(output + \"\\n\")  # Print the output to the console\n            sys.stdout.flush()  # Ensure it appears immediately\n    except Exception as e:\n        logging.error(f\"Error reading Stockfish output: {e}\")  # Log any errors\n## Function to wait for a specific marker in the output queue\ndef wait_for_marker(output_queue, marker):\n    \"\"\"\n    Wait for a specific marker in the output queue.\n\n    Args:\n        output_queue: Queue containing Stockfish output.\n        marker: The marker to wait for.\n    \"\"\"\n    try:\n        while True:  # Continuously check for the marker\n            output = output_queue.get()  # Get the next output line from the queue\n            if marker in output:  # If the marker is found in the output\n                logging.debug(f\"Marker '{marker}' found in output.\")  # Log that the marker was found\n                break  # Exit the loop\n    except Exception as e:\n        logging.error(f\"Error waiting for marker '{marker}': {e}\")  # Log any errors\n## Main function to run the remote Stockfish engine\ndef run_remote_stockfish(config):\n    \"\"\"\n    Starts the remote Stockfish engine using plink and processes input sequentially.\n\n    Args:\n        config: Dictionary containing configuration parameters.\n    \"\"\"\n## Build paths to plink and the key file\n    plink_path = os.path.abspath(config&#91;\"plink_path\"])\n    key_file_path = os.path.abspath(os.path.join(os.path.dirname(sys.argv&#91;0]), config&#91;\"key_file\"]))\n    host = config&#91;\"host\"]\n    username = config&#91;\"username\"]\n    remote_command = config&#91;\"stockfish_command\"]\n## Build the plink command to run Stockfish remotely\n    plink_command = &#91;\n        plink_path,\n        \"-batch\",  # Run in batch mode (non-interactive)\n        \"-ssh\",  # Use SSH for connection\n        \"-i\", key_file_path,  # Path to the private key file\n        f\"{username}@{host}\",  # Remote username and host\n        remote_command  # Command to run Stockfish on the remote server\n    ]\n    logging.info(f\"Plink command: {' '.join(plink_command)}\")  # Log the full command\n\n    try:\n## Start the plink process\n        process = subprocess.Popen(\n            plink_command,\n            stdin=subprocess.PIPE,  # Input to the process\n            stdout=subprocess.PIPE,  # Output from the process\n            stderr=subprocess.PIPE,  # Error output from the process\n            text=True,  # Use text mode for input\/output\n            bufsize=1  # Line buffering\n        )\n        logging.info(\"Plink process started successfully.\")  # Log success\n## Initialize synchronization tools\n        terminate_event = threading.Event()  # Event to signal thread termination\n        output_queue = queue.Queue()  # Queue to hold Stockfish output\n## Track if Stockfish is analyzing a position\n        is_analyzing = False\n        pending_command = None  # To store a queued command\n## Start a thread to handle Stockfish output\n        output_thread = threading.Thread(target=handle_output, args=(process, output_queue, terminate_event))\n        output_thread.daemon = True  # Run the thread in the background\n        output_thread.start()\n## Main loop to process user input\n        while True:\n            try:\n                user_input = input()  # Read user input from the console\n                logging.debug(f\"User input: {user_input.strip()}\")  # Log the input\n\n                if user_input.strip().lower() == \"quit\":  # Check for quit command\n                    process.stdin.write(user_input + \"\\n\")\n                    process.stdin.flush()\n                    terminate_event.set()  # Stop the output thread\n                    break\n\n                if is_analyzing and user_input.strip().lower() != \"stop\":\n## If the engine is analyzing, send \"stop\" before a new command\n                    logging.info(\"Engine is analyzing. Sending 'stop' command.\")\n                    pending_command = user_input\n                    process.stdin.write(\"stop\\n\")\n                    process.stdin.flush()\n                    wait_for_marker(output_queue, \"bestmove\")  # Wait for bestmove response\n                    is_analyzing = False\n                    continue\n## Send the command to Stockfish\n                process.stdin.write(user_input + \"\\n\")\n                process.stdin.flush()\n## Update the analyzing state based on the command\n                if user_input.strip().startswith(\"go infinite\"):\n                    is_analyzing = True\n                elif user_input.strip().lower() == \"stop\":\n                    is_analyzing = False\n## Handle specific markers for commands\n                if user_input.strip() == \"uci\":\n                    wait_for_marker(output_queue, \"uciok\")\n                elif user_input.strip() == \"isready\":\n                    wait_for_marker(output_queue, \"readyok\")\n                elif \"go\" in user_input and \"infinite\" not in user_input:\n                    wait_for_marker(output_queue, \"bestmove\")\n## Process any pending command after \"stop\"\n                if pending_command and not is_analyzing:\n                    logging.info(f\"Processing queued command: {pending_command.strip()}\")\n                    process.stdin.write(pending_command + \"\\n\")\n                    process.stdin.flush()\n                    pending_command = None\n\n            except EOFError:  # Handle end-of-file (e.g., when stdin closes)\n                logging.warning(\"EOFError: stdin closed unexpectedly.\")\n                terminate_event.set()\n                break\n            except KeyboardInterrupt:  # Handle Ctrl+C\n                logging.info(\"KeyboardInterrupt: Exiting...\")\n                terminate_event.set()\n                break\n            except Exception as e:  # Catch unexpected errors\n                logging.error(f\"Error processing user input: {e}\")\n## Wait for the output thread to finish\n        output_thread.join()\n## Terminate the plink process\n        process.terminate()\n        logging.info(\"Plink process terminated.\")\n\n    except Exception as e:\n        logging.error(f\"Error running Stockfish with Plink: {e}\")  # Log any errors\n    finally:\n        logging.info(\"Remote Stockfish wrapper terminated.\")  # Final cleanup log\n## Main script entry point\nif __name__ == \"__main__\":\n    config = load_config()  # Load configuration\n    setup_logging(config)  # Initialize logging\n    logging.info(\"Starting remote Stockfish wrapper.\")  # Log startup message\n    run_remote_stockfish(config)  # Run the main function<\/code><\/pre>\n\n\n\n<p>Summary of the code:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Logging Setup<\/strong>: Configures logging based on the\u00a0<code>config.json<\/code>\u00a0file, writing debug information and errors to a\u00a0<code>debug.log<\/code>\u00a0file when enabled.<\/li>\n\n\n\n<li><strong>Configuration Management<\/strong>: Loads customizable settings from a\u00a0<code>config.json<\/code>\u00a0file, including server IP (<code>host<\/code>), username, private key path (<code>key_file<\/code>),\u00a0<code>plink.exe<\/code>\u00a0path, Stockfish command, and logging preferences.<\/li>\n\n\n\n<li><strong>Stockfish Output Handling<\/strong>: Reads and processes output from Stockfish via\u00a0<code>plink.exe<\/code>, logs it, and uses a queue to manage sequential processing.<\/li>\n\n\n\n<li><strong>Marker Synchronization<\/strong>: Waits for specific markers (<code>uciok<\/code>,\u00a0<code>readyok<\/code>,\u00a0<code>bestmove<\/code>) in Stockfish&#8217;s output to ensure proper command synchronization.<\/li>\n\n\n\n<li><strong>Command Processing<\/strong>: Accepts user input from the terminal, handles common commands like\u00a0<code>uci<\/code>,\u00a0<code>isready<\/code>,\u00a0<code>go infinite<\/code>, and automatically sends\u00a0<code>stop<\/code>\u00a0if Stockfish is analyzing when new input is given.<\/li>\n\n\n\n<li><strong>Threading for Output<\/strong>: Runs Stockfish output handling in a separate thread, allowing real-time interaction and preventing blocking.<\/li>\n\n\n\n<li><strong>Plink Integration<\/strong>: Uses\u00a0<code>plink.exe<\/code>\u00a0to establish an SSH connection to the remote server, securely running Stockfish and relaying commands.<\/li>\n\n\n\n<li><strong>Error Handling<\/strong>: Catches and logs errors during configuration loading, Stockfish interaction, and terminal input.<\/li>\n\n\n\n<li><strong>Graceful Shutdown<\/strong>: Cleans up resources by terminating threads and the\u00a0<code>plink.exe<\/code>\u00a0process when the script exits or the\u00a0<code>quit<\/code>\u00a0command is issued.<\/li>\n<\/ul>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p><strong>Note:<\/strong>&nbsp;I\u2019m not a professional Python developer, but this script has been tested and should work for the most part. If you encounter any issues, they might require some minor troubleshooting or adjustments based on your specific setup. Feel free to modify the script to better suit your needs!<\/p>\n<\/blockquote>\n\n\n\n<h4 class=\"wp-block-heading\"><a href=\"https:\/\/lichess.org\/@\/HollowLeaf\/blog\/creating-your-own-stockfish-in-the-cloud\/uzjL07Hf#step-3-set-up-the-configuration-file-configjson\"><\/a><strong>Step 3: Set Up the Configuration File (<code>config.json<\/code>)<\/strong><\/h4>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Create a file named\u00a0<code>config.json<\/code>\u00a0in the same directory as your Python script. This file allows you to configure the proxy without modifying the script.<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code>{\n  \"host\": \"165.22.120.233\",\n  \"username\": \"root\",\n  \"key_file\": \"private.key.ppk\",\n  \"plink_path\": \"C:\\\\Program Files\\\\PuTTY\\\\plink.exe\",\n  \"stockfish_command\": \"stockfish\",\n  \"logging_enabled\": false\n}<\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Replace\u00a0<code>\"your_server_ip\"<\/code>\u00a0with the IP address of your droplet.<\/li>\n\n\n\n<li>Update\u00a0<code>\"key_file\"<\/code>\u00a0to point to the location of your private key (<code>.ppk<\/code>) file (this assume the same directory as the executable).<\/li>\n\n\n\n<li>Ensure\u00a0<code>\"plink_path\"<\/code>\u00a0points to the correct location of\u00a0<code>plink.exe<\/code>. By default, it is installed with PuTTY in:\u00a0<code>C:\\\\Program Files\\\\PuTTY\\\\plink.exe<\/code><\/li>\n\n\n\n<li>Set\u00a0<code>\"logging_enabled\"<\/code>\u00a0to\u00a0<code>true<\/code>\u00a0if you want logs saved in a\u00a0<code>debug.log<\/code>\u00a0file.<\/li>\n<\/ul>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p><strong>JSON (JavaScript Object Notation)<\/strong>&nbsp;is a lightweight data format used for storing and exchanging information in a structured way. It is easy for humans to read and write, while also being simple for machines to parse and generate. JSON represents data as key-value pairs, arrays, or nested objects, making it highly versatile for configuration files, APIs, and data serialization.<\/p>\n<\/blockquote>\n\n\n\n<h4 class=\"wp-block-heading\"><a href=\"https:\/\/lichess.org\/@\/HollowLeaf\/blog\/creating-your-own-stockfish-in-the-cloud\/uzjL07Hf#step-4-test-the-proxy-script\"><\/a><strong>Step 4: Test the Proxy Script<\/strong><\/h4>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Ensure that the\u00a0<code>remote_stockfish.py<\/code>,\u00a0<code>config.json<\/code>\u00a0and your private key is in the same directory.<\/li>\n\n\n\n<li>Open a command prompt, navigate to the script\u2019s directory, and run:\u00a0<code>python remote_stockfish.py<\/code><\/li>\n\n\n\n<li>The script will:\n<ul class=\"wp-block-list\">\n<li>Use\u00a0<code>plink.exe<\/code>\u00a0to connect to your server.<\/li>\n\n\n\n<li>Start Stockfish remotely.<\/li>\n\n\n\n<li>Relay commands between Chessbase and Stockfish.<\/li>\n\n\n\n<li>Type in\u00a0<code>uci<\/code>,\u00a0<code>isready<\/code>\u00a0to see the response. Type\u00a0<code>quit<\/code>\u00a0to exit stockfish.<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p><strong>Command Prompt Commands<\/strong><br>The Command Prompt is a built-in tool in Windows that allows users to interact with their computer through text-based commands. It provides a direct way to perform tasks such as navigating directories, managing files, and running programs without using the graphical interface. Command Prompt is often used for troubleshooting, automation, and accessing advanced features not available through the standard Windows interface. It\u2019s a powerful tool for both beginners and advanced users.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong><code>cd [folder name]<\/code><\/strong>: Change directory (move to a different folder).<\/li>\n\n\n\n<li><strong><code>cd ..<\/code><\/strong>: Go up one level to the parent folder.<\/li>\n\n\n\n<li><strong><code>cd \\<\/code><\/strong>: Return to the root directory of the drive.<\/li>\n\n\n\n<li><strong><code>dir<\/code><\/strong>: List all files and folders in the current directory.<\/li>\n\n\n\n<li><strong><code>[drive letter]:<\/code><\/strong>: Switch to a different drive.<\/li>\n\n\n\n<li><strong><code>[file name]<\/code><\/strong>: Run an executable file in the current directory.<\/li>\n\n\n\n<li><strong><code>cls<\/code><\/strong>: Clear all text from the Command Prompt screen.<\/li>\n\n\n\n<li><strong><code>cd<\/code><\/strong>: Display the current folder you\u2019re working in.<\/li>\n<\/ul>\n<\/blockquote>\n\n\n\n<h4 class=\"wp-block-heading\"><a href=\"https:\/\/lichess.org\/@\/HollowLeaf\/blog\/creating-your-own-stockfish-in-the-cloud\/uzjL07Hf#step-5-create-an-executable-with-pyinstaller\"><\/a><strong>Step 5: Create an Executable with pyInstaller<\/strong><\/h4>\n\n\n\n<p>PyInstaller is a powerful tool that allows you to convert Python scripts into standalone executables. These executables can run on systems without requiring a Python installation, making it easy to distribute and share your Python-based applications with others. PyInstaller packages your script, dependencies, and even configuration files into a single file or folder, ensuring everything needed to run the application is included.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Open a command prompt and run:\u00a0<code>pip install pyinstaller<\/code><\/li>\n\n\n\n<li>Use\u00a0<code>pyInstaller<\/code>\u00a0to package the Python script into a standalone executable:\u00a0<code>pyinstaller --onefile remote_stockfish.py<\/code><\/li>\n\n\n\n<li>After the process completes, you\u2019ll find the executable (<code>remote_stockfish.exe<\/code>) in the\u00a0<code>dist<\/code>\u00a0folder.<\/li>\n<\/ul>\n\n\n\n<h4 class=\"wp-block-heading\"><a href=\"https:\/\/lichess.org\/@\/HollowLeaf\/blog\/creating-your-own-stockfish-in-the-cloud\/uzjL07Hf#step-6-verify-and-configure-the-executable\"><\/a><strong>Step 6: Verify and Configure the Executable<\/strong><\/h4>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Ensure that\u00a0<code>remote_stockfish.exe<\/code>\u00a0and\u00a0<code>config.json<\/code>\u00a0are in the same directory. The script uses\u00a0<code>config.json<\/code>\u00a0for its settings, so this file must accompany the executable.<\/li>\n\n\n\n<li>Test the executable by running:\u00a0<code>remote_stockfish.exe<\/code><\/li>\n\n\n\n<li>If everything is set up correctly, the proxy will start, and Stockfish will run on your server via the executable.<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\"><a href=\"https:\/\/lichess.org\/@\/HollowLeaf\/blog\/creating-your-own-stockfish-in-the-cloud\/uzjL07Hf#6-connecting-the-remote-stockfish-engine-to-chessbase\"><\/a>6: Connecting the Remote Stockfish Engine to Chessbase<\/h2>\n\n\n\n<p>Now that your remote Stockfish engine is set up and accessible via the proxy script, the final step is to integrate it into Chessbase as a new engine. This allows Chessbase to communicate with the proxy, which in turn connects to Stockfish running on your server.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\"><a href=\"https:\/\/lichess.org\/@\/HollowLeaf\/blog\/creating-your-own-stockfish-in-the-cloud\/uzjL07Hf#step-1-open-chessbase-and-access-the-engine-management\"><\/a><strong>Step 1: Open Chessbase and Access the Engine Management<\/strong><\/h4>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Launch Chessbase on your computer.<\/li>\n\n\n\n<li>Navigate to the\u00a0<strong>Engines<\/strong>\u00a0menu and select\u00a0<strong>Create UCI Engine<\/strong>.<\/li>\n<\/ul>\n\n\n\n<h4 class=\"wp-block-heading\"><a href=\"https:\/\/lichess.org\/@\/HollowLeaf\/blog\/creating-your-own-stockfish-in-the-cloud\/uzjL07Hf#step-2-add-the-proxy-executable-as-a-new-engine\"><\/a><strong>Step 2: Add the Proxy Executable as a New Engine<\/strong><\/h4>\n\n\n\n<ul class=\"wp-block-list\">\n<li>In the\u00a0<strong>Create UCI Engine<\/strong>\u00a0dialog box:\n<ul class=\"wp-block-list\">\n<li>Click\u00a0<strong>Browse<\/strong>\u00a0and locate the\u00a0<code>remote_stockfish.exe<\/code>\u00a0file you created using\u00a0<code>pyInstaller<\/code>.<\/li>\n\n\n\n<li>Select the\u00a0<code>.exe<\/code>\u00a0file and click\u00a0<strong>Open<\/strong>.<\/li>\n\n\n\n<li>Give the engine a name (e.g., &#8220;<code>Stockfish (remote)<\/code>&#8220;).<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li>Leave other settings at their default values and click\u00a0<strong>OK<\/strong>.<\/li>\n<\/ul>\n\n\n\n<h4 class=\"wp-block-heading\"><a href=\"https:\/\/lichess.org\/@\/HollowLeaf\/blog\/creating-your-own-stockfish-in-the-cloud\/uzjL07Hf#step-3-test-the-engine\"><\/a><strong>Step 3: Test the Engine<\/strong><\/h4>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Once added, test the engine by analyzing a position:\n<ul class=\"wp-block-list\">\n<li>Open a chessboard or a game in Chessbase.<\/li>\n\n\n\n<li>Go to the\u00a0<strong>Engines<\/strong>\u00a0tab and select the newly added &#8220;Remote Stockfish&#8221; engine.<\/li>\n\n\n\n<li>Start the engine to see if it begins analyzing the position.<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n\n\n\n<h4 class=\"wp-block-heading\"><a href=\"https:\/\/lichess.org\/@\/HollowLeaf\/blog\/creating-your-own-stockfish-in-the-cloud\/uzjL07Hf#step-4-troubleshooting\"><\/a><strong>Step 4: Troubleshooting<\/strong><\/h4>\n\n\n\n<p>If the engine doesn\u2019t connect or analyze:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Ensure that your\u00a0<code>remote_stockfish.exe<\/code>\u00a0and\u00a0<code>config.json<\/code>\u00a0files are in the same directory.<\/li>\n\n\n\n<li>Verify that your Python proxy script is properly configured (e.g., correct server IP, SSH key path, and plink.exe location).<\/li>\n\n\n\n<li>Check that your server is running and Stockfish is accessible remotely.<\/li>\n\n\n\n<li>Enable logging in\u00a0<code>config.json<\/code>\u00a0by setting\u00a0<code>\"logging_enabled\": true<\/code>\u00a0to check the\u00a0<code>debug.log<\/code>\u00a0file for errors.<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\"><a href=\"https:\/\/lichess.org\/@\/HollowLeaf\/blog\/creating-your-own-stockfish-in-the-cloud\/uzjL07Hf#summary\"><\/a>Summary<\/h2>\n\n\n\n<p>In this guide, we\u2019ve walked through the entire process of setting up and using a remote Stockfish engine in the cloud. Starting with creating a secure and cost-effective server on DigitalOcean, we installed Stockfish on Ubuntu and configured secure SSH communication using PuTTY. We then built a Python-based proxy to connect Chessbase to the remote engine, allowing seamless communication between your chess software and the powerful Stockfish engine hosted in the cloud. Finally, we integrated the proxy into Chessbase, enabling high-performance analysis without relying on local computing resources.<br>By following these steps, you now have a scalable and flexible setup that combines the power of cloud computing with the capabilities of Stockfish and Chessbase. Whether you\u2019re analyzing games, exploring complex positions, or running multi-threaded analysis, this setup gives you the tools to take your chess studies to the next level. Have fun experimenting, learning, and improving your chess with this robust setup!<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<h3 class=\"wp-block-heading\"><a href=\"https:\/\/lichess.org\/@\/HollowLeaf\/blog\/creating-your-own-stockfish-in-the-cloud\/uzjL07Hf#note-on-improving-security\"><\/a><strong>Note on Improving Security<\/strong><\/h3>\n\n\n\n<p>The primary aim of this blog was to help you get up and running with a remote Stockfish setup. However, for enhanced security, you should consider implementing the following measures:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Create a Non-Root User<\/strong>\u00a0to limit privileges for routine connections.<\/li>\n\n\n\n<li><strong>Whitelist Your IP<\/strong>\u00a0to restrict server access to your own computer.<\/li>\n\n\n\n<li><strong>Disable Password Authentication<\/strong>\u00a0to enforce key-based SSH logins.<\/li>\n\n\n\n<li><strong>Change the Default SSH Port<\/strong>\u00a0to reduce the risk of automated attacks.<\/li>\n\n\n\n<li><strong>Enable a Firewall<\/strong>\u00a0to allow only necessary ports, such as SSH.<\/li>\n\n\n\n<li><strong>Regularly Update Software<\/strong>\u00a0to ensure the latest security patches are applied.<\/li>\n\n\n\n<li><strong>Monitor Access Logs<\/strong>\u00a0to identify unauthorized login attempts.<\/li>\n\n\n\n<li><strong>Set Up Fail2Ban<\/strong>\u00a0to block IPs with repeated failed login attempts.<\/li>\n\n\n\n<li><strong>Use Strong Private Key Passphrases<\/strong>\u00a0to protect your SSH keys.<\/li>\n\n\n\n<li><strong>Enable Two-Factor Authentication (2FA)<\/strong>\u00a0for added SSH security.<\/li>\n<\/ul>\n\n\n\n<p>If you&#8217;re unsure how to implement the security measures mentioned above, you can use tools like ChatGPT or other AI assistants to guide you step-by-step. Simply ask for detailed instructions on topics like creating non-root users, configuring firewalls, or setting up Fail2Ban, and you&#8217;ll receive tailored advice to help you secure your server effectively.<\/p>\n<\/blockquote>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<h3 class=\"wp-block-heading\"><a href=\"https:\/\/lichess.org\/@\/HollowLeaf\/blog\/creating-your-own-stockfish-in-the-cloud\/uzjL07Hf#important-note-2\"><\/a><strong>Important Note<\/strong><\/h3>\n\n\n\n<p>Now that you\u2019ve completed the setup, don\u2019t forget to&nbsp;<strong>tear down your Droplet<\/strong>&nbsp;to avoid incurring unnecessary costs! Digital Ocean charges even if your Droplet is off.<\/p>\n<\/blockquote>\n\n\n\n<p>I hope you enjoyed this blog and found it helpful! If you have any questions or need assistance, feel free to leave a comment in the section below.<a href=\"https:\/\/lichess.org\/@\/HollowLeaf\/blog\"><\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Setting up Stockfish in the cloud can be a game-changer for chess enthusiasts and professionals alike. By leveraging the power of cloud computing, you can access high-performance chess analysis from any device, even if your personal laptop or desktop is underpowered. Whether you want faster calculations, the ability to run multiple analysis sessions, or just [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":57,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-56","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/blog.chessboardmagic.com\/index.php\/wp-json\/wp\/v2\/posts\/56","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.chessboardmagic.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.chessboardmagic.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.chessboardmagic.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.chessboardmagic.com\/index.php\/wp-json\/wp\/v2\/comments?post=56"}],"version-history":[{"count":2,"href":"https:\/\/blog.chessboardmagic.com\/index.php\/wp-json\/wp\/v2\/posts\/56\/revisions"}],"predecessor-version":[{"id":59,"href":"https:\/\/blog.chessboardmagic.com\/index.php\/wp-json\/wp\/v2\/posts\/56\/revisions\/59"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/blog.chessboardmagic.com\/index.php\/wp-json\/wp\/v2\/media\/57"}],"wp:attachment":[{"href":"https:\/\/blog.chessboardmagic.com\/index.php\/wp-json\/wp\/v2\/media?parent=56"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.chessboardmagic.com\/index.php\/wp-json\/wp\/v2\/categories?post=56"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.chessboardmagic.com\/index.php\/wp-json\/wp\/v2\/tags?post=56"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}