etckeeper pushing to github
To preserve the current ssh keys for when you're in root, use sudo -E
.
That way there's no need to add anything to the root ssh config
One thing you can do is specify a key to use for one repo and set it as a remote in your git repository.
Meaning you can put this in root's ~/.ssh/config
:
Host gitupstream
HostName example.org
User git
IdentityFile /home/<user>/.ssh/id_rsa.pub
Assuming you git remote add gitupstream [email protected]:/myrepo
in this case then do git push origin gitupstream
.
If anyone has an issue with git still trying to use id_rsa instead of the key specified in /root/.ssh/config, here's my fix for it.
The following are my test configuration files before fixing them:
/root/.ssh/config:
Host bitbucket
HostName bitbucket.org
User git
IdentityFile /root/.ssh/bitbucket.pub
[repo]/.git/config:
[core]
repositoryformatversion = 0
filemode = true
bare = false
logallrefupdates = true
[remote "origin"]
url = [email protected]:trae32566/test.git
fetch = +refs/heads/*:refs/remotes/origin/*
There are two problems with this:
- SSH seems to require you to use the "Host" variable in place of [user]@[address|domain]
- The configuration file seems to need the private key.
To fix the first problem I edited line 7 in [repo]/.git/config from:
url = [email protected]:trae32566/test.git
to:
url = bitbucket:trae32566/test.git
To fix the second problem I edited line 4 in /root/.ssh/config from:
IdentityFile /root/.ssh/bitbucket.pub
to:
IdentityFile /root/.ssh/bitbucket
source: http://www.cyberciti.biz/faq/create-ssh-config-file-on-linux-unix/