Safekeeping /etc on GitHub with etckeeper

  • Ubuntu
  • Etckeeper
  • OpenSSH ssh-keygen
  • Git
  • GitHub

I’ve always had a personal Linux server floating around the web for email and webhosting and playing with things. I’ve been using Git for a while now and thought “gee, it would be super cool if I just committed my /etc to a repo”. I discovered the sweet etckeeper(https://etckeeper.branchable.com/) by Joey Hess (https://joeyh.name/). It’s been around for a while but it’s new to me.

Since /etc is where most if not all the configuration of your Linux box is, it is very important to keep track of changes. Some sudoer could mess things up, something malicious could get in there and mess things up. For the safety and security of your system etckeeper is a must have.

This does put things into GitHub that are sensitive so keep it provate and if you don’t trust GitHub than don’t do it.

I found many instructions and tutorials online but as usual nothing quite fits 100% of my needs. I want to have etckeeper push to GitHub(github). This is my story!

Install and configure Git

sudo apt install git -y

Etckeeper has git as dependency, but I found some config is needed to make things run smoothly. Login using your normal sudo-enabled user, but you will also need to su into root as well. Set your own values here of course.

As your normal sudo user:
git config –global user.name “Leroy Jackson”
git config –global user.email “leroy@example.com

Now su up to root and set those configs again. It seems etckeeper uses root’s info to commit and push.

As root:
git config –global user.name “Bob the Bionic Beaver”
git config –global user.email “bob@example.com

Ok, Git is all ready to go!

Install and configure Etckeeper

sudo apt install etckeeper -y

In Ubuntu, it defaults to use git and will automatically init and commit all of /etc during install. This is one of the reasons I had you configure the git user settings first. Otherwise it grabs something like root@hostname, yuck.

It uses the master branch, this is hard coded in the scripts which is a bummer.

sudo nano /etc/etckeeper/etckeeper.conf

Review etckeeper config and set the PUSH_REMOTE=”origin”. Make sure VCS=”git” is uncommented. Also note it will make a commit daily or any changes. I like this behavior but you can disable it here. Save and exit.

Ok, Etckeeper is all set.