Disclaimer: This resource is for educational purposes only. Mining is against the terms and policies of most cloud service providers. To mine on most platforms, you are required to obtain a written permission to from them.
A variety of platforms offering cloud computing services offer great virtual machines that allow you to launch an instance remotely and in real time. For the sake of this tutorial, I shall be demonstrating with the Google Cloud Platform.
Mining on the cloud is not so profitable because, in the end, you’ll end up spending more on virtual machines and getting less in the value of cryptocurrency mined through the machines.
Hence, if you would be mining on a virtual machine for profit, that would be a pretty insane thing to do. Mining on a free-trial plan can also get your projects suspended.
Without much ado, let’s get started mining some crypto!
1. GET YOUR VIRTUAL MACHINE RUNNING
After signing up on Google Cloud Console or AWS Cloud Compute, the next thing you would like to do is to launch an instance. An instance is a virtual machine with independent or shared components depending on how it is configured for the launch.
Select Compute Engine > VM Instances from the menu and wait for the VM Instances page to load. Click on CREATE INSTANCE and wait for the instance setup screen to come up.

Because mining is CPU-intensive, we want to choose a higher CPU plan. Ensure the Boot Disk Operating System is Ubuntu or Debian distros of Linux and select the e2-highcpu-8 since you are mining with a new account. Google defaults new accounts to a maximum of 8 vCPUs per project.

Select the SSH option to connect to the Virtual Machine Instance and your instance will start booting.

2. UPDATE YOUR VIRTUAL MACHINE OPERATING SYSTEM
You need to update your Virtual Machine’s Operating System for better performance and optimized running of processes. To do this, copy and paste the command below into your VM’s terminal.
sudo apt-get update

The command above fetches the latest version of the package list from the distro’s software repository and third-party repositories you might have configured. This allows you to avoid glitches that may arise as a result of outdated dependencies or incompatible applications.
3. DOWNLOAD AND EXTRACT THE XMRIG LINUX SOFTWARE
The XMRIG is a well-known and vast software used in mining cryptocurrencies based on the RandomX algorithms and a few others. It is used to mine Cryptos such as Monero, Raptoreum, Nano and Zephyr.
The XMRIG GitHub releases can be found here. Right-click on the Linux version you want to download on your virtual machine. We will be using the 6.21.0 version of the static Linux release in this tutorial. We will also use the wget command to get the file download link. Run the code below next.
wget https://github.com/xmrig/xmrig/releases/download/v6.21.0/xmrig-6.21.0-linux-static-x64.tar.gz

After the installation, you can check the file you installed and you should see an archived tar.gz file when you use the list command below
ls

The next thing you wanna do is to extract the archived file. Enter the command line below to extract the file.
tar -xf xmrig-6.21.0-linux-static-x64.tar.gz ; ls
Then boom, it is extracted and a new directory is added to our desktop folder and the folder list is printed to your screen.

Now, we have a folder named xmrig-6.21.0 that contains the extracted files.
4. CHANGE DIRECTORY AND CONFIGURE THE CONFIG.JSON FILE
To open the folder that contains the directory, we need to switch to the folder. The next thing we would like to do is see the contents of the folder after switching to it.
cd xmrig-6.21.0/ ; ls
The code above switches into the xmrig-6.21.0 folder and lists the content. Use the command above to do that on your end as well.

Now it is time to edit the config.json file. This file contains the configuration for the miner and you are to enter the pool URL and your wallet in the file.
Open the config.json file with the vi editor using the command below.
vi config.json
The editor is now open. You cannot edit immediately when you open a file using the vi editor. You need to press the letter i key to switch to the insert mode before you can edit the file. After switching to the insert mode, scroll down and look for the URL (input the pool address and the port eg xmrig.nanswap.com:3333) and user (enter your wallet address) and modify it to your taste.
Popular pools that work with Xmrig include Nanswap for mining Nano (XNO) and Herominers for mining Monero (XMR), Zephyr (ZEPH) and a few others.

After entering the right wallet and pool address, press the Escape (Esc) key to exit the insert mode and type ‘:wq‘ command which allows you to write (save) and quit the vi editor.
5. START MINING CRYPTO!
Now that you have configured the config.json file and exited the vi editor window, it is time to start mining some crypto. Enter the command below and the miner should get started.
./xmrig

Voila! We are now mining Crypto on our virtual machine.
6. Conclusion: Automating XMRIG and Reducing the CPU
If you are looking to automate the XMRIG miner to keep working, I recommend you install tmux. While some VMs like Amazon’s EC2 instances come with tmux preinstalled, on Google Cloud’s VM you would have to install it manually.
It is also crucial to reduce the number of threads being used by the miner so that the VM’s CPU does not get heated in time.
If you want to learn how to reduce or increase the CPU usage or tmux setup, you would have to scroll up to watch my YouTube video on how to set that up.