# Git inside distrobox

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1762466356486/b7e0d632-e2a6-4891-aca9-eade505072dd.png align="center")

I ran this command from inside a distrobox. Because of old habits I installed git inside the distrobox. This message made me wonder how to approach this situtaion. Should I config everything in the host machine and have it somehow transfered to the distrobox when needed? Or let go with doing `git` inside distroboxes?

> Because Distrobox mounts the host's $HOME, running git config --global modifies the single, shared ~/.gitconfig file used by both the container and the host.

Ok, cool. We can move on as if we were on the same machine. What about SSH keys?

Well, we already know that the whole `$HOME` is passed on, so the keys at `~/.ssh` are also available to the distrobox. It seems that we need to ensure that the host’s `ssh-agent` is running then:

> Distrobox typically passes required variables automatically, including `$SSH_AUTH_SOCK`, when you use the `distrobox enter` command.

I could also write yet another post on how to deal with keys but these links below will help:

* [https://docs.github.com/en/authentication/connecting-to-github-with-ssh/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent](https://docs.github.com/en/authentication/connecting-to-github-with-ssh/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent)
    
    * I usually create one key per user/device instead of doing it “per service”.
        
    * I don’t use my email to create the key, instead: `ssh-keygen -t ed25519 -C "username@hostname"`
        
* [https://docs.github.com/en/authentication/connecting-to-github-with-ssh/adding-a-new-ssh-key-to-your-github-account](https://docs.github.com/en/authentication/connecting-to-github-with-ssh/adding-a-new-ssh-key-to-your-github-account)
    

OK! I created a key and will try to use it inside a distrobox now.

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1762517288928/f1562f25-4b32-42aa-9960-508c2d0f6e28.png align="center")

It just works! Out of the box, well, in this case… anyways. I only had to answer `yes` to add `github.com` to my `knowhosts` file and is working. Time for me to go back to the parent article of this one.

Ops, forgot to add some important configuration. For the `user.name` I use the same from `github.com` but I believe you can use anything you want. And for the `user.email` I recommend enabling the private email option on `github.com` settings page(see below) and use that `@users.noreply.github.com` email they provide.

```bash
git config --global user.name "aviler" && git config --global user.email "399399+aviler@users.noreply.github.com"
```

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1762519996263/2c8177a3-89e2-408e-8ea3-7b579f930aef.png align="center")
