How to Securely Setup an Ethereum Node
π₯ Video Link
sudo add-apt-repository -y ppa:ethereum/ethereum
sudo apt-get update
sudo apt-get install geth
Add ethereum repository and install geth β Link to section in video
sudo useradd --no-create-home --shell /bin/false user_name_goes_here
Create new user β Link to section in video
cat /etc/passwd | grep user_name_goes_here
Verify user was created
pwd
Print current directory
mkdir -p /your/path/chain/data
Create data directory β Link to section in video
sudo chown -R user_name_goes_here:user_name_goes_here /your/path/chain/data
Grant new user access to new folder β Link to section in video
sudo gedit /etc/systemd/system/geth.service
Open the service file with gedit β Link to section in video
[Unit]
Description=Go Ethereum Client
After=network.target
Wants=network.target
[Service]
User=user_name_goes_here
Group=group_name_goes_here
Type=simple
Restart=always
RestartSec=5
ExecStart=geth --datadir /your/path/chain/data --port your_port --syncmode "full" --cache=1024 --http --metrics --maxpeers 30
[Install]
WantedBy=default.target
Service file contents β Link to section in video
sudo systemctl daemon-reload
Reload service daemon
sudo systemctl start geth
Start the service β Link to section in video
sudo systemctl status geth
Check the service status β Link to section in video
sudo journalctl -fu geth.service
Show service logs β Link to section in video
sudo systemctl enable geth
Enable service to start at boot β Link to section in video
sudo systemctl disable geth
Disable service to start at boot
sudo geth attach --datadir /your/path/chain/data
Attach to geth service β Link to section in video
eth.syncing
Show ethereum syncing status
var lastPercentage = 0;var lastBlocksToGo = 0;var timeInterval = 10000;
setInterval(function(){
var percentage = eth.syncing.currentBlock/eth.syncing.highestBlock*100;
var percentagePerTime = percentage - lastPercentage;
var blocksToGo = eth.syncing.highestBlock - eth.syncing.currentBlock;
var bps = (lastBlocksToGo - blocksToGo) / (timeInterval / 1000)
var etas = 100 / percentagePerTime * (timeInterval / 1000)
var etaM = parseInt(etas/60,10);
console.log(parseInt(percentage,10)+'% ETA: '+etaM+' minutes @ '+bps+'bps');
lastPercentage = percentage;lastBlocksToGo = blocksToGo;
},timeInterval);
Sync status script
Links referenced for video
- https://portchecktool.com
- https://someresat.medium.com/guide-to-staking-on-ethereum-2-0-ubuntu-prysm-56f681646f74
- https://ethereum.org/en/developers/docs/nodes-and-clients/
- https://geth.ethereum.org/docs/install-and-build/installing-geth#install-on-ubuntu-via-ppas
- https://theryanmiller.com/running-an-ethereum-full-node-using-geth.html
- https://gist.github.com/dleonard00/980ceca4be2c6542dc95efbca9313cfd β Geth Sync Status Script