Find the answer to your Linux question:
Results 1 to 2 of 2
I need to create a tar file of all of the authorized_keys files in a directory and / or it's subdirectories. I have this: find /chroot/home/ -type f -name authorized_keys ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Jul 2010
    Posts
    15

    Tar of authorized_keys in unknown directories script


    I need to create a tar file of all of the authorized_keys files in a directory and / or it's subdirectories.

    I have this:
    find /chroot/home/ -type f -name authorized_keys

    How can I create a tar file of whatever it finds? I need to do it automatically so that I can have a cron job that backs up all of the authorized_keys into a folder.

    Actually need the directory path too, like:
    /chroot/home/mrjohn/.ssh/authorized_keys

    That way I could restore it if needed.

  2. #2
    Trusted Penguin
    Join Date
    May 2011
    Posts
    4,353
    just throw the tar command in front of your find command, and put the find command in backticks, e.g.:
    Code:
    tar -cf /tmp/mykeys.tar `find /chroot/home/ -type f -name authorized_keys`
    It will save the full path (less the beginning '/') in the tarball.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •