Skip to content

age encryption fails on passing an SSH key #529

@danial23

Description

@danial23

Describe the bug

I want to use age encryption with my ssh keys. I tried setting the AGE_PUBLIC_KEYS_FILE env var to point to a file which contains two comma-separated age recipients with the ssh-ed25519 public key format. Running the backup command results in the following error:

time=2025-02-04T04:41:24.278Z level=INFO msg="Created backup of `/backup` at `/tmp/backup-2025-02-04T04-41-23.tar.gz`."
time=2025-02-04T04:41:24.293Z level=INFO msg="Removed tar file `/tmp/backup-2025-02-04T04-41-23.tar.gz`."
time=2025-02-04T04:41:24.293Z level=ERROR msg="Fatal error running command: malformed recipient \"ssh-ed25519 [REDACTED]\": mixed case" error="main.(*command).runAsCommand: error running script: main.runScript.func4: error running script: main.(*script).encryptArchive: failed to get configured age recipients: main.(*script).getConfiguredAgeRecipients: failed to parse age public key: malformed recipient \"ssh-ed25519 [REDACTED]\": mixed case"

To Reproduce
Steps to reproduce the behavior:

  1. Create a file named age_recipients containing two ssh-ed25519 public keys separated by a comma:
ssh-ed25519 [some key],ssh-ed25519 [some key]
  1. Launch the docker service with a compose.yml file similar to this:
services:
  ...
  docker-volume-backup:
    image: offen/docker-volume-backup:v2
    container_name: docker-volume-backup
    secrets:
      - DOCKER_VOLUME_BACKUP_AGE_PUBLIC_KEYS
    environment:
      AGE_PUBLIC_KEYS_FILE: /run/secrets/DOCKER_VOLUME_BACKUP_AGE_PUBLIC_KEYS
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock:ro
      ...
      - ${HOME}/backup:/archive
secrets:
  DOCKER_VOLUME_BACKUP_AGE_PUBLIC_KEYS:
    file: ./age_recipients
  1. Run docker exec -it docker-volume-backup sh
  2. Type backup and press Enter

Expected behavior

An encrypted archive saved to the ~/backup directory

Version (please complete the following information):

  • Image Version: v2.43.1
  • Docker Version: 27.5.1
  • Docker Compose Version (if applicable): v2.32.4

Additional context

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions