ML
    • Recent
    • Categories
    • Tags
    • Popular
    • Users
    • Groups
    • Register
    • Login

    Cron GPG Scripts can't locate the Keyring

    IT Discussion
    gpg shell
    2
    5
    561
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • wirestyle22W
      wirestyle22
      last edited by wirestyle22

      I made a basic script to encrypt everything contained in a specific directory as a test

      gpg —batch —recipient 8A4YA9YC —encrypt  —yes /directory/to/encrypt/*
      find . -name '.txt' -exec mv {} /home/datatransfer/company/archive/out/ \;
      

      The key here isn't real.

      If I run the script manually it works. If I try to run it with cron it errors with encryption failed: No public key.

      It clearly can't see the path to the key, so I tried to find a way to specify it.

      gpg —batch --homedir /home/serviceaccount/.gnupg/pubring.gpg —recipient 8A4YA9YC —encrypt  —yes /directory/to/encrypt/*
      

      Same error: encryption failed: No public key

      1 Reply Last reply Reply Quote 0
      • JaredBuschJ
        JaredBusch
        last edited by

        You are running it manually as your user and in a cron as root.

        wirestyle22W 1 Reply Last reply Reply Quote 0
        • wirestyle22W
          wirestyle22 @JaredBusch
          last edited by

          @JaredBusch I'm running it as root in both instances to test

          1 Reply Last reply Reply Quote 0
          • wirestyle22W
            wirestyle22
            last edited by wirestyle22

            Alright I see one thing I did wrong was specify a file rather than a directory.

            gpg —batch --homedir /home/serviceaccount/.gnupg/pubring.gpg —recipient 8A4YA9YC —encrypt  —yes /directory/to/encrypt/*
            

            has been changed to

            gpg —batch --homedir /home/serviceaccount/.gnupg/ —recipient 8A4YA9YC —encrypt  —yes /directory/to/encrypt/*
            
            1 Reply Last reply Reply Quote 0
            • wirestyle22W
              wirestyle22
              last edited by

              That seems to have fixed the issue

              1 Reply Last reply Reply Quote 0
              • 1 / 1
              • First post
                Last post