Say you have a script or something that gets run in cron/task scheduler and it needs a password… say to ssh to a raspberry pi elsewhere in your house.

How do you save that password in a way that automation can access it?

Some ideas:

  • Plaintext file. Not a fan because its sitting unencrypted on the box somewhere.
  • Environment variable. Not a fan because its still unencrypted somewhere to someone on the box (albeit likely the same user or an admin).
  • A secrets manager. If I use something locally like hashicorp vault or infisical, I can get to a point where a cli/api call gets the password. Though in this case I still need a vault password/secret to get my password. So I fall back to needing one of the above to get this to work.

If the secrets manager is easily available, the secret to get into the secrets manager is available as well leading to a feeling of security by obscurity.

If someone breaks into my system via SSH/etc. then they can get the passwords either way.

… How do people normally do this? I’m not sure I actually get anything out of a secrets manager if its local and I have the disk itself encrypted before login.

What actually makes sense at a personal/home scale?

(Edit: I know using SSH key probably is better for getting to the raspberry pi, but still the question is the same idea).

  • chenxiaolong@lemm.ee
    link
    fedilink
    English
    arrow-up
    20
    ·
    1 year ago

    If you want to get fancy: systemd credentials. It can store the secrets encrypted on disk and seal the encryption key with the TPM chip. The encrypted secret is decrypted (non-interactively) and made available only to a specific systemd service. The process itself does not special systemd integration–it just sees a plain text file containing the secret, backed by a tmpfs that’s not visible to other processes.

    Depending on which TPM PCRs you bind to, you can choose how secure you want it to be. A reasonable/usable configuration would be something like binding to PCRs 7 and 14. With that setup, the TPM will not unseal the key if the system is booted into any other OS (i.e. anything signed with a different UEFI Secure Boot key). But if you really want to lock things down, you can bind to additional PCRs and make it so changing any hardware, boot order, BIOS setting, etc. will prevent the TPM from unsealing the key.

  • zazu@sh.itjust.works
    link
    fedilink
    English
    arrow-up
    6
    ·
    edit-2
    1 year ago

    Hashicorp Vault + Vault Config Operator + external-secrets. I have a simple chart that can add credentials to different apps which mostly gets used in argocd with its multichart functionality. A simple bash script to create the vault policies, which use the k8s back end to allow auth.

  • mim@lemmy.sdf.org
    link
    fedilink
    English
    arrow-up
    4
    ·
    edit-2
    1 year ago

    I use shh keys for all my remote machines, set passwords automatically with ansible, and store them with pass.

    https://www.passwordstore.org/

    EDIT:

    Just to clarify, ansible can use pass as a password store, so in the ansible playbooks you can write which password you want to retrieve from pass.

    You can also call pass from any shell script by writing $(pass <target_password>)

    • 486@kbin.social
      link
      fedilink
      arrow-up
      3
      ·
      1 year ago

      Ansible also comes with its own secrets manager ansible-vault, which you can also use to store your secrets in an encrypted file.

      • mim@lemmy.sdf.org
        link
        fedilink
        arrow-up
        1
        ·
        1 year ago

        Yeah I’ve been meaning to look into it.

        Just went with pass because it’s what I’m used to, and it’s pretty straightforward. But definitely next on my to-do list.

  • Tarte@kbin.social
    link
    fedilink
    arrow-up
    4
    ·
    edit-2
    1 year ago

    I generate a unique key pair (or token) for each service that I want to access from the host machine. I see no issue with storing that dedicated private key locally in plaintext (obviously in a folder where only the required user can read it and I except it from backup and versioning). I use one dedicated user per externally accessible service.

    Should the machine itself become compromised this would indicate that my personal master key and master password have been compromised or someone gained physical access. That would require me to restart from a blank page anyways.

  • Obsession@sh.itjust.works
    link
    fedilink
    English
    arrow-up
    2
    ·
    1 year ago

    I’m on Kubernetes with ArgoCD gitops.

    I use sealedsecrets, so all my secrets are in git encrypted. The encryption key is in my keepass vault.

  • tbblake@lemmy.world
    link
    fedilink
    English
    arrow-up
    2
    ·
    edit-2
    1 year ago

    Not ideal but a few scattered ssh agents I unlock on reboot. And zabbix to tell me if they’re not running.

  • IanTwenty@lemmy.world
    link
    fedilink
    English
    arrow-up
    2
    ·
    1 year ago

    Two more options you might consider:

    • secret-tool - like a vault that unlocks when a user logs in to their session. This shifts the problem to keeping the user’s login credentials secure but depending on your setup that might be preferable. Just be aware the once unlocked any process could access the vault in theory (I wish they’d add access controls…)
    • podman secrets - so you can securely provide secrets to containers. You can set these once securely then nothing except processes in the container can get them.
    • csm10495@sh.itjust.worksOP
      link
      fedilink
      English
      arrow-up
      2
      ·
      1 year ago

      This is likely a too late, but reasonable moment to say this server happens to be Windows based.

      … for backup reasons.

      (The tool used for online backup only allows home versions of Windows and local drives)

      One day if I build a new one, I might start with a Linux base, though that kind of requires this one to be on its last leg before I get to that point. It’s running a processor/mobo that are 14ish years old… so maybe I should think more about it.

      • IanTwenty@lemmy.world
        link
        fedilink
        English
        arrow-up
        2
        ·
        1 year ago

        In that case I’ll also mention that Powershell has a secure-string that allows you to load secrets from encrypted file/user input. I believe it’s secured by the user’s login/session like secret-tool. They are even remain encrypted in memory so they can’t be snooped on.

    • csm10495@sh.itjust.worksOP
      link
      fedilink
      English
      arrow-up
      1
      ·
      1 year ago

      Yeah… but I think its overkill. The root cert would be on the same box somewhere nearby. Compromising the host has the same issue as plaintext.

    • csm10495@sh.itjust.worksOP
      link
      fedilink
      English
      arrow-up
      2
      ·
      edit-2
      1 year ago

      The problem is that would be so annoying/impractical. In an optimal world, yeah a person checking a prompt and approving could make sense, but in practice that would also mean that the MFA prompt would have to ask for the password anyways. (Or the password would be on the phone with the same problem as on the computer).

      Can you imagine having to type a password on an hourly schedule or something? If the password was cached, we have the same problem again.