dev-environments
dev-environments copied to clipboard
Cannot clone repository with ssh on Windows
Describe the bug Cannot clone repository with ssh from github or other platform.
To Reproduce Steps to reproduce the behavior:
- Start ssh-agent for git bash
- Add pub key to github
- ssh-add ~/.ssh/id_PRIVATE
- Create dev environment, try to clone with ssh
- The message is in the Screenshots part.
- Start ssh-agent on WSL2(Ubuntu) which is integrated with docker desktop
- ssh-add ~/.ssh/id_PRIVATE
- retry step 4 and got the same as step 5
Expected behavior
git clone [email protected]:argoproj/argo-rollouts.git could work
Screenshots

Desktop (please complete the following information):
- Windows11 Pro 22H2
- WSL2(Ubuntu 22.04.1)
Version of Docker Desktop:
Version 4.14.0 (91374)
docker version
Client: Docker Engine - Community
Version: 20.10.21
API version: 1.41
Go version: go1.18.7
Git commit: baeda1f
Built: Tue Oct 25 18:02:21 2022
OS/Arch: linux/amd64
Context: default
Experimental: true
Server: Docker Desktop
Engine:
Version: 20.10.21
API version: 1.41 (minimum version 1.12)
Go version: go1.18.7
Git commit: 3056208
Built: Tue Oct 25 18:00:19 2022
OS/Arch: linux/amd64
Experimental: false
containerd:
Version: 1.6.9
GitCommit: 1c90a442489720eec95342e1789ee8a5e1b9536f
runc:
Version: 1.1.4
GitCommit: v1.1.4-0-g5fd4c4d
docker-init:
Version: 0.19.0
GitCommit: de40ad0
docker info
Client:
Context: default
Debug Mode: false
Plugins:
app: Docker App (Docker Inc., v0.9.1-beta3)
buildx: Docker Buildx (Docker Inc., v0.9.1)
compose: Docker Compose (Docker Inc., v2.12.2)
dev: Docker Dev Environments (Docker Inc., v0.0.3)
extension: Manages Docker extensions (Docker Inc., v0.2.13)
sbom: View the packaged-based Software Bill Of Materials (SBOM) for an image (Anchore Inc., 0.6.0)
scan: Docker Scan (Docker Inc., v0.21.0)
Server:
Containers: 0
Running: 0
Paused: 0
Stopped: 0
Images: 0
Server Version: 20.10.21
Storage Driver: overlay2
Backing Filesystem: extfs
Supports d_type: true
Native Overlay Diff: true
userxattr: false
Logging Driver: json-file
Cgroup Driver: cgroupfs
Cgroup Version: 1
Plugins:
Volume: local
Network: bridge host ipvlan macvlan null overlay
Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog
Swarm: inactive
Runtimes: io.containerd.runc.v2 io.containerd.runtime.v1.linux runc
Default Runtime: runc
Init Binary: docker-init
containerd version: 1c90a442489720eec95342e1789ee8a5e1b9536f
runc version: v1.1.4-0-g5fd4c4d
init version: de40ad0
Security Options:
seccomp
Profile: default
Kernel Version: 5.15.68.1-microsoft-standard-WSL2
Operating System: Docker Desktop
OSType: linux
Architecture: x86_64
CPUs: 4
Total Memory: 7.761GiB
Name: docker-desktop
ID: QXA4:RJXE:E6QF:3ZEW:PKPF:RAQR:IXEE:OISQ:NPJP:DEVZ:UMSW:OXB7
Docker Root Dir: /var/lib/docker
Debug Mode: false
HTTP Proxy: http.docker.internal:3128
HTTPS Proxy: http.docker.internal:3128
No Proxy: hubproxy.docker.internal
Registry: https://index.docker.io/v1/
Labels:
Experimental: false
Insecure Registries:
hubproxy.docker.internal:5000
127.0.0.0/8
Live Restore Enabled: false
WARNING: No blkio throttle.read_bps_device support
WARNING: No blkio throttle.write_bps_device support
WARNING: No blkio throttle.read_iops_device support
WARNING: No blkio throttle.write_iops_device support
Additional context Start ssh agent for git bash on windows (~/.profile)
env=~/.ssh/agent.env
agent_load_env () { test -f "$env" && . "$env" >| /dev/null ; }
agent_start () {
(umask 077; ssh-agent >| "$env")
. "$env" >| /dev/null ; }
agent_load_env
# agent_run_state: 0=agent running w/ key; 1=agent w/o key; 2=agent not running
agent_run_state=$(ssh-add -l >| /dev/null 2>&1; echo $?)
if [ ! "$SSH_AUTH_SOCK" ] || [ $agent_run_state = 2 ]; then
agent_start
ssh-add
elif [ "$SSH_AUTH_SOCK" ] && [ $agent_run_state = 1 ]; then
ssh-add
fi
unset env
Start ssh agent for WSL2(~/.profile)
SSH_ENV="$HOME/.ssh/agent-environment"
function start_agent {
echo "Initialising new SSH agent..."
/usr/bin/ssh-agent | sed 's/^echo/#echo/' > "${SSH_ENV}"
echo succeeded
chmod 600 "${SSH_ENV}"
. "${SSH_ENV}" > /dev/null
}
# Source SSH settings, if applicable
if [ -f "${SSH_ENV}" ]; then
. "${SSH_ENV}" > /dev/null
ps -ef | grep ${SSH_AGENT_PID} | grep ssh-agent$ > /dev/null || {
start_agent;
}
else
start_agent;
fi
Reolved. Maybe the docker documentation is not correct. Either git bash nor WSL2 cannot work. Only ssh-add on Windows can work.
PS C:\Users\hzh> Set-Service -Name ssh-agent -StartupType Manual
PS C:\Users\hzh> Start-Service ssh-agent
PS C:\Users\hzh> ssh-add -l
The agent has no identities.
PS C:\Users\hzh> ssh-add C:\Users\hzh\.ssh\id_ed25519
Identity added: C:\Users\hzh\.ssh\id_ed25519 (hzh@Win11-PC)
PS C:\Users\hzh>
But another issue.
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
exit code 128
And sometimes hangs while cloning.
Preparing to clone inside a volume
Installing credential helpers...
done
Cloning into '/com.docker.devenvironments.code'...
Cloning from both Powershell and Git Bash works well.
I have the similar problem. It will be stuck at Cloning into '/com.docker.devenvironments.code'...
When I entry the docker/desktop-git-helper container to run ssh -v -T [email protected] and the log will be stuck at below 👇
debug1: Server host key: ssh-ed25519 SHA256:+DiY3wvvV6TuJJhbpZisF/zLDA0zPMSvHdkr4UvCOqU
debug1: load_hostkeys: fopen /root/.ssh/known_hosts: No such file or directory
debug1: load_hostkeys: fopen /root/.ssh/known_hosts2: No such file or directory
debug1: load_hostkeys: fopen /etc/ssh/ssh_known_hosts2: No such file or directory
debug1: Host 'github.com' is known and matches the ED25519 host key.
debug1: Found key in /etc/ssh/ssh_known_hosts:12
debug1: rekey out after 134217728 blocks
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: rekey in after 134217728 blocks
I have come up with a temporary solution. Using the https://xxx when creating environment and it will success. Open in vscode and start a terminal so you can change the repository url like this 👇
git remote set-url origin [email protected]:xxxx
Still hangs. Did someone find a fix?
Hanging still, anything?
still hanging