Open flaprimo opened 1 month ago
Hi @flaprimo, thanks for reporting the issue. Have you tried to use SSH Agent forwarding instead of mounting your ssh directory as a whole?
If you SSH agent is active, DevPod automatically forwards your private keys from %USERPROFILE%/.ssh
to the workspace unless you opt-out through the context option SSH_AGENT_FORWARDING
.
Hi @pascalbreuninger thank you for the prompt response.
I've verified that the SSH agent is running on Windows:
PS C:\Users\XYZ> Get-Service ssh-agent
Status Name DisplayName
------ ---- -----------
Running ssh-agent OpenSSH Authentication Agent
I've removed as you suggested:
devcontainer.json
:
"mounts": [
"source=${localEnv:HOME}${localEnv:USERPROFILE}/.ssh,target=/home/vscode/.ssh,type=bind,consistency=cached"
]
./.devcontainer/postCreateCommand.sh
:
chmod 700 ~/.ssh
chmod 600 ~/.ssh/*
But I still cannot perform git operations:
vscode ➜ /workspaces/XXXX $ git pull
ssh: Could not resolve hostname YYYY: Name or service not known
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
To note that in my .ssh/config
on Windows I have setup the remote with an alias like so:
Host YYYY
HostName ssh.dev.azure.com
IdentitiesOnly yes
IdentityFile ~/.ssh/XYZ
Credentials are not copied over (should I expect that?):
$ ls ~/.ssh
ls: cannot access '/home/vscode/.ssh': No such file or directory
Ah I see, I wasn't aware of the SSH config for you git hoster.
Can you try to recreate this config in your devcontainer but remove the IdentityFile
?
And can you confirm running ssh-add -L
in your devcontainer has the correct public keys for the identity you need to authenticate against azure?
Thank you! It seems that we achieved some things:
ssh-add -L
on the Host and the dev container I obtain the same list, so ssh agent forwarding seems to work indeed.IdentityFile
also seems to allow the alias to work:
Host YYYY
HostName ssh.dev.azure.com
IdentitiesOnly yes
BUT, when trying to do a git pull
, it doesn't seem to pair automatically the ssh key:
$ git pull
The authenticity of host 'ssh.dev.azure.com (XXXX)' can't be established.
RSA key fingerprint is SHA256:XXXX.
This key is not known by any other names.
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
Warning: Permanently added 'ssh.dev.azure.com' (RSA) to the list of known hosts.
git@ssh.dev.azure.com's password:
What happened? I cannot use Git inside the dev container with imported SSH credentials from Windows to interact with the repository. The error is "Bad owner or permissions on /home/vscode/.ssh/config".
What did you expect to happen instead?
To leverage the imported SSH credentials to interact with Git.
How can we reproduce the bug? (as minimally and precisely as possible)
My
devcontainer.json
:with "./.devcontainer/postCreateCommand.sh":
Local Environment:
DevPod Provider:
Anything else we need to know?
credentials seem to be mounted correctly inside the container and the permission in the script to be applied.