Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Vovans/0c986b423d0fc5b47d7ce81fb78da361 to your computer and use it in GitHub Desktop.
Save Vovans/0c986b423d0fc5b47d7ce81fb78da361 to your computer and use it in GitHub Desktop.
#!/bin/bash
# Solana validator remote identity transfer script v1.0
#
# Before starting, both validators must be running and caught up.
# For the best experience, use ssh keys without a password.
#
# Created: 30 Sep 2023 by STEVLTH
# Discord: .stevlth
# Telegram: https://t.me/STEVLTH
########## CONFIG ######################################################
SOLANA_PATH="/root/.local/share/solana/install/active_release/bin" # Solana binary directory.
STAKED_IDENTITY="" # The path to the JSON file on your laptop, not on the server!!!
UNSTAKED_IDENTITY="" # The path to the JSON file on your laptop, not on the server!!! It will be created by this script.
SERVER_LEDGER_PATH="" # Make sure the ledger paths are the same on both servers, or consider creating a symlink for convenience.
SERVER_TOWER_PATH=$SERVER_LEDGER_PATH # By default, the tower file is stored in the ledger directory, but you can use a custom path. Make sure the paths to the tower file are the same on both servers.
SERVER_FROM="" # user@IP - the server running Solana validator with the STAKED identity.
SERVER_TO="" # user@IP - the server running Solana validator with the UNSTAKED identity.
########## END CONFIG ##################################################
echo -e "You are going to transfer $(solana address -k $STAKED_IDENTITY) (STAKED identity)\nFROM $SERVER_FROM\nTO $SERVER_TO"
echo
while true; do
read -p "Are you sure? " yn
case $yn in
[Yy]* ) echo; echo "Starting..."; break;;
[Nn]* ) echo; echo "Aborting..."; exit;;
* ) echo; echo "Please enter Yes(y) or No(n).";;
esac
done
echo
solana-keygen new -s --no-bip39-passphrase --force -o $UNSTAKED_IDENTITY
echo "New UNSTAKED identity: $(solana address -k $UNSTAKED_IDENTITY)"
echo
echo "SET UNSTAKED identity to $SERVER_FROM..."
ssh $SERVER_FROM "$SOLANA_PATH/solana-validator --ledger $SERVER_LEDGER_PATH set-identity" < $UNSTAKED_IDENTITY
echo "REMOVE all authorized voters from $SERVER_FROM..."
ssh $SERVER_FROM "$SOLANA_PATH/solana-validator --ledger $SERVER_LEDGER_PATH authorized-voter remove-all"
echo
echo "Copy tower file from $SERVER_FROM..."
scp $SERVER_FROM:$SERVER_TOWER_PATH/tower-1_9-$(solana address -k $STAKED_IDENTITY).bin $HOME
echo "Copy tower file to $SERVER_TO..."
scp $HOME/tower-1_9-$(solana address -k $STAKED_IDENTITY).bin $SERVER_TO:$SERVER_TOWER_PATH
echo
echo "SET STAKED identity to $SERVER_TO..."
ssh $SERVER_TO "$SOLANA_PATH/solana-validator --ledger $SERVER_LEDGER_PATH set-identity" < $STAKED_IDENTITY
echo "SET STAKED authorized voter to $SERVER_TO..."
ssh $SERVER_TO "$SOLANA_PATH/solana-validator --ledger $SERVER_LEDGER_PATH authorized-voter add" < $STAKED_IDENTITY
echo
echo "DONE"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment