GaMa
Posted on September 18, 2017
Due to work I faced the need of using two or more GitHub accounts, sometimes I need to use the accounts in the same machine. I've been trying to use the following solution:
However I couldn't make it to work, by the time I was experimenting with Docker and I got the idea of using a container to just push my changes. So far I haven't identify any security related problems, obviously never expose the container to internet just start it push your changes and stop it, or script it to launch it add the new ssh keys to github push then destroy the container.
The solution is quite simple, start a new container from the image I created in an earlier post: Creating the Docker image
First of all pull the image:
docker pull drverboten/multigitaccount
Then create a new container from the image, but add the path of the source code or any other resource you want to add to your repo as a volume with the -v option:
docker run -it --name gitpub -v /home/[user]/[path to workspace]:/workspace drverboten/multigitaccount /bin/sh
After the container is running, create a new ssh key with the following command:
ssh-keygen -t rsa -b 4096 -C "[email]"
Copy your key to the clipboard you can just cat and copy the text:
cat ~/.ssh/id_rsa.pub
Add the key to GitHub
Back in the container configure git:
git config --global user.email "[email]"
git config --global user.name "[username]"
And you are all set, just push to GitHub as you normally do, it will post as the configured user.
👻✌ï¸
Posted on September 18, 2017
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.
Related
June 19, 2024