The settings in /etc/ are kept in Git repositories so I can restore them easily when something breaks badly. It also allows me to check when I modified a file and why I did it. And it gives me the ability to merge settings from one machine onto the other one easily because all machines use the same repository, just a different branch.
When committing changes as root, the user name and email address are often not mine but root@hostname, which is misleading and gives very poor change logs when multiple admins commit changes.
The multiple admins issue is what prevents me from using
$ git config user.name "Christian Weiske"
Apart from the global and repository configuration settings, Git reads the environment variables GIT_AUTHOR_NAME, GIT_AUTHOR_EMAIL, GIT_COMMITTER_NAME and GIT_COMMITTER_EMAIL. The idea now is to set them on your machine and take them via SSH on every single machine.
At first you need to set the variables in your .bashrc file:
export GIT_AUTHOR_NAME="Christian Weiske" export GIT_AUTHOR_EMAILfirstname.lastname@example.org export GIT_COMMITTER_NAME="$GIT_AUTHOR_NAME" export GIT_COMMITTER_EMAIL="$GIT_AUTHOR_EMAIL"
Now either start a new shell or reload your current bash settings:
$ source ~/.bashrc
Local ssh configuration
Add the following line to your ~/.ssh/config file:
SendEnv LANG LC_* GIT_*
LANG and LC_* get transmitted by default, just have a look at /etc/ssh/ssh_config - we just add all the Git ones.
If you put that line at the top, before any special Host settings, it will affect all hosts.
Remote daemon setup
At least in Ubuntu 11.10 and Debian 6, sshd only accepts the LANG and LC_* variables, as seen in /etc/ssh/sshd_config:
AcceptEnv LANG LC_*
We modify the line and allow all the Git variables:
AcceptEnv LANG LC_* GIT_*
Now a quick SSH daemon reload to get it pick up the new configuration settings and we are set:
$ /etc/init.d/ssh reload $ exit $ ssh root@machine $ echo $GIT_AUTHOR_NAME Christian Weiske