Everybody has some, but nobody notices them. Devices that are always running, 24 hours a day, 7 days a week, just sitting around collecting dust. But not anymore, there is a way we can take advantage of all that wasted potential. If you have any old laptops, a Raspberry Pi, an unused VPS or anything else that runs a more or less recent version of linux then today is your lucky day. It is very easy to setup a headless browser and do some quick javascript mining - you probably won't get rich this way but it's a fun project and a great intro into the giant world of mining.
For simplicity let's assume you're running a Debian based distribution, in my example below I'll use Ubuntu Server 16.04 64bit.
First we install Google Chrome. Starting with Version 59 it is shipped with a new headless mode which enables it to run on headless systems (Systems without monitor, mouse and keyboard). To do so we add the Google repository and it's key to our sources, update the source list and then install Google Chrome.
# execute as root
wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add -
echo 'deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main' | tee /etc/apt/sources.list.d/google-chrome.list
apt-get update
apt-get install google-chrome-stable
Now just for convenience let's write a little startup script, that way there is no need to do so much typing every time you want to restart Chrome or even the whole server. To do so switch back to your user account (running this as root is not the most secure thing you can do but if you insist, please add the --no-sandbox flag.) and go to your home folder. This can be done by typing
cd $HOME
Now we create a new file, set the permissions to allow for execution and paste the chrome command into it. I will describe the content in just a minute, hold on.
touch mine.sh
chmod +x mine.sh
echo "/opt/google/chrome/chrome --headless --disable-gpu --remote-debugging-port=9222 --user-agent='user-agent=Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.113 Safari/537.36' 'https://coinhive.com/media/miner.html?autostart=1&key=GoI0WOEe2JFj22Aj3JqYVcTt98LArmUX'" > mine.sh
This last line opens chrome in headless mode, disables the gpu, enables remote debugging on port 9222 and sets the user agent to hide the fact that we are headless. This is all followed by the website which actually provides the whole mining setup. In this case I have created a very simple coinhive miner. Please remember to change the Key in this address to your own or you will mine coins for me ;)
The remote debugging can be very useful, especially if things don't work like they should. It provides a frontend to the headless browser which can be accessed on the defined port above using your own browser and enables you to actually see something. More infos can be found here
Depending on your network setup you may need to setup some kind of port forwarding to reach this debugger. The easiest thing to do would be SSH tunneling, which can be done like this.
ssh -L 9222:localhost:9222 user@yourserver
To keep the program running even if we close the terminal we can simply use nohup. Just enter the following and the mining will begin.
nohup /$HOME/mine.sh&
Now all we need to do is close the terminal, sit back and relax while stuff we never use generates some money for us.
great info! Im following you since you have good posts!
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
Thanks :)
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit