This is a run down of this article - Link! On how to access your git accounts from within your running devcontainers using SSH.
- Add openssh-client to your Dockerfile
RUN apt-get update && \ apt-get install -y --no-install-recommends \ git \ curl \ unzip \ stow \ zsh \ openssh-client \ # <-- ADD && \ # Clean up the apt cache to keep the image size small rm -rf /var/lib/apt/lists/*
- Allow Agent Forwarding
Host s1 HostName stash.stil.dk AddKeysToAgent yes User x151998 UseKeychain yes IdentityFile ~/.ssh/id_rsa.stil ForwardAgent yes # <-- ADD
- Start your devcontainer
How to test the setup
root# echo $SSH_AUTH_SOCK /tmp/vscode-ssh-auth-secret.sock root# ssh-add -l 2048 SHA256:finger sukkerfrit@secret.local (RSA) root# ssh -T git@github.com Hi sukkergris! You've successfully authenticated, but GitHub does not provide shell access.
Now let's enable the usage of aliases!
- Add .ssh to your dotfiles
Host g1 HostName github.com User git ForwardAgent yes PreferredAuthentications publickey
So, if you like me ara using aliases you can now use git from within your container :)
Vola!
Top comments (0)