I have installed atuin on a bunch of servers, 70+ at least.
I install it via chezmoi with a “run after” script, where I fetch the password and key from keyhole which is a password manager that uses your ssh key to access the secrets - very useful for bootstrapping the “first secret”.
I have had some issues where the secret fetch failed, which I didn’t notice and a following sync botched the server-side copy with un-decryptable history entries, that then propagated to all my other servers at login due to auto sync.
I still experience this sometimes, when my script tries to login but the secret fetch fails.
Thanks to the new version the bad history no longer propagates but stays on the new host. If I run my login script a second time it succeeds, but now I already have a few history entries encrypted with a key I don’t have access to.
if atuin status &> /dev/null; then
echo "Atuin is already logged in."
atuin status
else
echo "Atuin is not logged in. Logging in..."
# Here I inspect hostnames to determine the correct username
# I self-host and have different usernames for different environments
export ATUIN_USERNAME="username"
if [[ -n "$ATUIN_USERNAME" ]]; then
ATUIN_PASSWORD="$(ssh -o StrictHostKeyChecking=accept-new keyhole.example.com get atuin/$ATUIN_USERNAME/password)"
ATUIN_KEY="$(ssh -o StrictHostKeyChecking=accept-new keyhole.example.com get atuin/$ATUIN_USERNAME/key)"
if [[ -z "$ATUIN_PASSWORD" || -z "$ATUIN_KEY" ]]; then
echo "Failed to retrieve Atuin credentials - Skipping atuin login."
else
atuin login \
--username "$ATUIN_USERNAME" \
--password "$ATUIN_PASSWORD" \
--key "$ATUIN_KEY"
fi
else
echo "Unknown host type - Skipping atuin login."
fi
fi
I believe this script should work, but I think that auto sync might try to sync without a propper key configured, which then leads to “bad history” when I do login with the correct key and password.
I have submitted a PR with a command atuin store repair that can repair the local history by either uploading readable history entries, or fetching history entries we have locally but can’t read.
I have used this on my own atuin server to successfully repair my history store.
A feature like what openconnect, has where you can login and supply your secrets on stdin would be most welcome, as my current way of logging in exposes the secrets in the process list for a brief period.
Something like echo "password\nkey" | atuin login --username user --stdin, then replace echo with your favourite secret manager.