vault_dump

command module
v0.3.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 6, 2021 License: BSD-3-Clause Imports: 1 Imported by: 0

README

Vault Dump

Description

Dumps and restores secrets from Hashicorp Vault into GPG2 encrypted JSON files.

Disclaimer

⚠ This is a personal project and my first real venture into Golang, I cannot guarantee that a restore will be consistent with what was previously backed up. Use this code at your own risk!

Supported secret mount types
  • KV (v1)
  • KV (v2)
  • Transit

Usage

For help, run ./vault_dump --help

Dump and restore secrets from Hashicorp Vault

Usage:
  vault_dump [flags]
  vault_dump [command]

Available Commands:
  completion  generate the autocompletion script for the specified shell
  dump        Dump Vault to an encrypted JSON file
  help        Help about any command
  restore     Restore an encrypted JSON dump to Vault

Flags:
  -x, --debug     enable debug output
  -h, --help      help for vault_dump
  -j, --json      print logs in JSON format
  -v, --version   show vault_dump version

Use "vault_dump [command] --help" for more information about a command.
Dump prerequisites

To dump, you need to ensure you have the following:

  • Network access to your Vault instance, with the VAULT_ADDR environment variable defined.

  • To be authenticated with Vault (uses VAULT_TOKEN environment variable or .vault-token file in your home directory).

  • An GPG2 key that you have the private key for, you only need the public key to encrypt, however to decrypt you will need the corresponding private key.

  • Permission to list and read secrets, sample policy below:

    path "*" {
        capabilities = ["read", "list"]
    }
    

Example dump command using multiple public keys:

$ ./vault_dump \
    dump \
    --file="$(date +%s).json.asc" \
    --key=me.at.email.com.pub \  # This is one public key
    --key=you.at.email.com.pub   # This is another public key

Example dump command using a private key (not recommended):

$ ./vault_dump \
    dump \
    --file="$(date +%s).json.asc" \
    --passphrase="yo_r-Str0ng-Pa55-phRaSe" \ # This can also be specified with VAULT_DUMP_PASSPHRASE environment variable
    --key=me.at.email.com.asc  # This is a private key
Restore prerequisites

To restore a dump, you will need the following:

  • Network access to your Vault instance, with the VAULT_ADDR environment variable defined.
  • To be authenticated with Vault (uses VAULT_TOKEN environment variable or .vault-token file in your home directory).
  • The secret portion of the GPG key used to encrypt the dump.
  • The passphrase for the GPG key secret.
  • Mount points to already be present in Vault (vault_dump will attempt to re-create mounts if you specify the --recreate-mounts flag, however this is not default behavior).
  • Write access to each mount.

Example command:

$ ./vault_dump \
    restore \
    --file="somedump.json.asc" \
    --passphrase="yo_r-Str0ng-Pa55-phRaSe" \ # This can also be specified with VAULT_DUMP_PASSPHRASE environment variable
    [email protected] \ # This is a private key
    --recreate-mounts # attempts to re-create mounts from a dump.
Container image

You can download the container image from hub.docker.com:

$ docker pull pyratlabs/vault-dump:latest
$ podman pull docker.io/pyratlabs/vault-dump:latest

License

BSD 3-Clause

Documentation

Overview

Copyright © 2021 Xan Manning <[email protected]> All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

  1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
  1. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
  1. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
JackTT - Gopher 🇻🇳