How to change the security key or merge two histories on a dedicated server?

I identified the root cause of problems with one atuin deployment of mine: I’ve registered with a wrong key to my private atuin server.

I have already accumulated important pieces of shell history on that machine, and I would prefer not lose it.

I know I would be able to solve this problem if I could dump the history un-encrypted into a file, and imported it back after I am logged in with the correct security key.

I am aware of the Feature atuin import from file by mijoharas · Pull Request #2170 · atuinsh/atuin · GitHub , but this work seems not finished.

I know I can export just the typed commands to the fish format using Feature request: export history to local history file · Issue #1073 · atuinsh/atuin · GitHub and then re-import it - but that will cause last datetime of each command to be lost.

Do you have any suggestions to me?

Thank you in advance for your time in reading this post.

When you say wrong key, do you mean that you have several different machines that are logged in to the same account, but have different keys?

You can use

atuin store rekey THE_NEW_KEY

If you’d like to re-encrypt local data with a new key, and then replace the old key.

atuin store rekey -h
Re-encrypt the store with a new key (potential for data loss!)

Usage: atuin store rekey [KEY]

Arguments:
  [KEY]  The new key to use for encryption. Omit for a randomly-generated key

Options:
  -h, --help  Print help

Lmk if that’s the problem you’re having - there are then commands you can run to clean up the remote history, and the synced store on your other machines

Thank you Ellie for a swift reply. I really appreciate your effort to write and - most importantly - maintain such a great productivity tool!

Here’s a follow up:

$ atuin store rekey "<base64-encoded key from the other system from .local/share/atuin/key>"
Re-encrypting store with freshly-generated key
Error: attempting to decrypt with incorrect key. currently using k4.lid.vZGDtIeLxDkjVYK3mxbqpTd8VMQj8Mu-2Ij_2yDLNl5_, expecting k4.lid.8Ax0VB7cKPfWj0jK1UeayDs15O3ixpk7A4wO6gL6TQJK

Location:
    /home/adam/.cargo/registry/src/index.crates.io-6f17d22bba15001f/atuin-client-18.2.0/src/record/encryption.rs:132:9

What does it mean? I can still see all the history on this system, spanning back 8 months with atuin history list.

I don’t think that I have made an error with setting up a storage with a wrong key - I remember being careful not to do that, when I set up this system. I could have still made that mistake, or something changed the key in mid-flight. But then, if that is the case, why can I access the history?

BTW, the system that exhibits this problem with a key is a WSL2 container (under Windows).

Here’s a doctor’s output:

Atuin Doctor
Checking for diagnostics


Please include the output below with any bug reports or issues

atuin:
  version: 18.2.0
  sync:
    cloud: false
    records: true
    auto_sync: true
    last_sync: 2024-10-16 13:51:29.182912097 +00:00:00
shell:
  name: bash
  default: unknown
  plugins:
  - atuin
  - bash-preexec
system:
  os: Ubuntu
  arch: x86_64
  version: '22.04'
  disks:
  - name: none
    filesystem: overlay
  - name: drivers
    filesystem: 9p
  - name: /dev/sdc
    filesystem: ext4
  - name: /dev/sdc
    filesystem: ext4
  - name: none
    filesystem: overlay
  - name: none
    filesystem: overlay
  - name: none
    filesystem: overlay
  - name: C:\134
    filesystem: 9p
  - name: C:\134
    filesystem: 9p
  - name: C:\134
    filesystem: 9p
  - name: C:\134
    filesystem: 9p
  - name: /dev/sdc
    filesystem: ext4
  - name: snapfuse
    filesystem: fuse.snapfuse
  - name: snapfuse
    filesystem: fuse.snapfuse
  - name: snapfuse
    filesystem: fuse.snapfuse
  - name: snapfuse
    filesystem: fuse.snapfuse
  - name: snapfuse
    filesystem: fuse.snapfuse
  - name: snapfuse
    filesystem: fuse.snapfuse
  - name: snapfuse
    filesystem: fuse.snapfuse
  - name: snapfuse
    filesystem: fuse.snapfuse
  - name: snapfuse
    filesystem: fuse.snapfuse
  - name: snapfuse
    filesystem: fuse.snapfuse
  - name: snapfuse
    filesystem: fuse.snapfuse
  - name: snapfuse
    filesystem: fuse.snapfuse
  - name: snapfuse
    filesystem: fuse.snapfuse
  - name: snapfuse
    filesystem: fuse.snapfuse
  - name: snapfuse
    filesystem: fuse.snapfuse
  - name: snapfuse
    filesystem: fuse.snapfuse
  - name: snapfuse
    filesystem: fuse.snapfuse
  - name: snapfuse
    filesystem: fuse.snapfuse
  - name: snapfuse
    filesystem: fuse.snapfuse
  - name: snapfuse
    filesystem: fuse.snapfuse
  - name: snapfuse
    filesystem: fuse.snapfuse
  - name: snapfuse
    filesystem: fuse.snapfuse
  - name: snapfuse
    filesystem: fuse.snapfuse
  - name: /dev/sdc
    filesystem: ext4