Setting Up HashiCorp Vault (dev) + EthSigner
HashiCorp Vault dev server is a fast and convenient way to set up a Vault server instance. However, its security level is lower than a non-dev server. For one, all secrets are stored in memory, as opposed to encrypted storage in a non-dev server. In addition, the server connection is TLS-disabled. Finally, the dev server gives you 1 unseal key to unseal the Vault, whereas the non-dev server requires you to enter 3 of 5 keys to unseal the Vault.
Install HashiCorp Vault
sudo apt updateupdates apt-installed packages
sudo apt install gpg wgetinstalls gpg (GNU Privacy Guard), which is a cryptography library, and wget, which is like curl but used mostly for downloading files
wget -O- https://apt.releases.hashicorp.com/gpg | sudo gpg --dearmor -o /usr/share/keyrings/hashicorp-archive-keyring.gpgIf you get a certificate verification error, use
wget -O- https://apt.releases.hashicorp.com/gpg --no-check-certificate | sudo gpg --dearmor -o /usr/share/keyrings/hashicorp-archive-keyring.gpgThis downloads a "keyring" from Hashicorp and puts it into the file defined by the last part of the command (the pipe key "|" takes ouput of statement before and uses it as the input for the statement after)
gpg --no-default-keyring --keyring /usr/share/keyrings/hashicorp-archive-keyring.gpg --fingerprintThis verifies the keyring
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/hashicorp-archive-keyring.gpg] https://apt.releases.hashicorp.com $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/hashicorp.listThis writes the string in the quotes to the file after the pipe key ("|"). The string is a command to use the "deb" package manager to download a repo from the https url. The package is signed by the key ring you downloaded earlier. "$lsb_release -cs" prints the version of Ubuntu of your system.
sudo apt update && sudo apt install vaultThis installs Vault using the apt package manager
Check installation with
vaultandvault --version
Download and unzip EthSigner
sudo apt-get install openjdk-17-jdkInstalls Java 17 (must use Java 17, not Java 11); 500MB
download ethsigner.tar.gz file (.tar.gz is like a .zip file) in link:
cd into the folder where you want the folder extracted
tar -xzvf filename.tar.gzextracts the files into a folder called "ethsigner-23.6.0"
check permissions of the ethsigner binary (a binary is an executable file)
cd into "ethsigner-23.6.0" folder, cd into "bin" folder
run
ls, you should see the files "ethsigner" and "ethsigner.bat"run
ls -l ./ethsigner, ensure you have "x" (executable) permissions. If not, then runchmod +x ./ethsigner
check ethsigner binary works
cd into "ethsigner-23.6.0" folder
./bin/ethsigner --help
Run a Vault dev server in tmux
Create new tmux window called "vault" with
tmux new -s vaultvault server -devYou should see the "Unseal Key" and "Root Token"
copy the "Root Token" to a temporary place (we will use it later)
Leave tmux window with
ctrl + b, thendSet env vars:
export VAULT_ADDR='http://127.0.0.1:8200'export VAULT_TOKEN="hvs.6j4cuewowBGit65rheNoceI7"replace string with your token
check env vars with
envTODO: Later, in the Authentication tutorial, you will learn to use the vault login <token_value> command to authenticate with Vault
save Root Token into "authFile" file in ethsigner-23.6.0/bin folder
cd into "ethsigner-23.6.0" folder, cd into "bin" folder
touch authFilevim authFilepress "i" to go into "insert mode"
copy Root Token string into first line
ctrl + cto quit "insert" mode, then write/quite with:wqcheck authFile by reading it with
cat authFile
Check if Vault server running with
vault statusImport private key into HashiCorp Vault
vault kv put secret/ethsignerSigningKey value=<privateKeyWithout0x>
Run EthSigner server in tmux
cd into "ethsigner-23.6.0" folder
create new tmux window called "ethsigner" with
tmux new -s ethsigner./bin/ethsigner --chain-id=137 --downstream-http-port=443 hashicorp-signer --host=127.0.0.1 --port=8200 --auth-file=./bin/authFile --tls-enabled=false --signing-key-path=/v1/secret/data/ethsignerSigningKeyLeave tmux window with
ctrl + b, thendCheck EthSigner server is running
test1:
curl -X GET http://127.0.0.1:8545/upcheckSuccess should show "I'm up!"
test2:
curl -X POST --data '{"jsonrpc":"2.0","method":"eth_accounts","params":[],"id":1}' http://127.0.0.1:8545Success should show your address
Seal the Vault with
vault operator sealSuccess shows: "Success! Vault is sealed."
With the Vault sealed, you cannot access secrets with
vault kv getUnseal Vault with
vault operator unsealand enter the single Unseal KeyAn unsealed Vault is needed to import secrets and initialize EthSigner
(if needed) run the NodeJS App (see Local Server)
View all running servers with
tmux ls
Test
Send a Trading View alert or mimic one using sendAlert.js. If you already set up Ngrok, use the Ngrok URL as the webhook URL. If not, your NodeJS App should be listening on http://localhost:8080/. If using the "localhost" URL, you must run node sendAlert.js on the same machine.
A successful test should show transaction details the the swap hash in the console.
Last updated