-
-
Notifications
You must be signed in to change notification settings - Fork 675
fix: start container only after attach in ddev auth ssh
, fixes #7664
#7681
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Download the artifacts for this pull request:
See Testing a PR. |
8ce4184
to
9761d02
Compare
Rebased. |
ddev auth ssh
, fixes #7664ddev auth ssh
, fixes #7664
cmd/ddev/cmd/auth-ssh.go
Outdated
config := &dockerContainer.Config{ | ||
Image: docker.GetSSHAuthImage() + "-built", | ||
Cmd: dockerStrslice.StrSlice{"bash", "-c", `cp -r /tmp/sshtmp ~/.ssh && chmod -R go-rwx ~/.ssh && cd ~/.ssh && mapfile -t keys < <(grep -l '^-----BEGIN .* PRIVATE KEY-----' *) && ((${#keys[@]})) || { echo "No SSH private keys found" >&2; exit 1; } && for key in "${keys[@]}"; do ssh-add "$key" || exit $?; done`}, | ||
Cmd: dockerStrslice.StrSlice{"bash", "-c", `cp -r /tmp/sshtmp ~/.ssh && chmod -R go-rwx ~/.ssh && cd ~/.ssh && mapfile -t keys < <(grep -l '^-----BEGIN .* PRIVATE KEY-----' *) && ((${#keys[@]})) || { echo "No SSH private keys found" >&2; exit 1; } && for key in "${keys[@]}"; do printf "\nRunning command: ssh-add %s\n" "$key"; ssh-add "$key" || exit $?; done`}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Most people don't know what ssh-add
is or what it means in this context. Maybe simplify to "Adding key %s" ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
In addition, I fixed the output for ddev auth ssh -j
, it should only produce JSON output.
This comment was marked as outdated.
This comment was marked as outdated.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I retested (without this) and was able to replicate the problem on WSL2.
Then I used this and it worked perfectly:
rfay@ubuntu-len:~/workspace/ddev$ ddev poweroff
The ddev-ssh-agent container has been removed. When you start it again you will have to use 'ddev auth ssh' to provide key authentication again.
rfay@ubuntu-len:~/workspace/ddev$ ddev auth ssh
Network ddev_default created
[+] Pulling 7/7
✔ ddev-ddev-ssh-agent-20250824_akibaat_buildx_arm_builder Pulled 1.9s
✔ d107e437f729 Already exists 0.0s
✔ 19e48215f278 Already exists 0.0s
✔ 44b7382c3380 Already exists 0.0s
✔ 4f4fb700ef54 Already exists 0.0s
✔ df9423e98b41 Already exists 0.0s
✔ e41c6c43a147 Already exists 0.0s
Container ddev-ssh-agent Created
Container ddev-ssh-agent Started
ssh-agent container is running: If you want to add authentication to the ssh-agent container, run 'ddev auth ssh' to enable your keys.
Adding 3 SSH private key(s)...
Adding key id_ed25519
Enter passphrase for id_ed25519:
Identity added: id_ed25519 (andreas@LS-PC-42)
Adding key id_rsa
Enter passphrase for id_rsa:
Identity added: id_rsa (andreas@LS-PC-42)
Adding key id_rsa (new 2022-12-27)
Enter passphrase for id_rsa (new 2022-12-27):
Identity added: id_rsa (new 2022-12-27) (id_rsa (new 2022-12-27))
Successfully added 3 SSH private key(s).
The Issue
ddev auth ssh
hangs on Windows with WSL2 if first key has password #7664How This PR Solves The Issue
ssh-add
.ddev/ddev-ssh-agent
, because it doesn't show that it pulls it when there are no DDEV images.ddev auth ssh -j
output. (It should always be JSON compatible.)Manual Testing Instructions
Prepare keys:
key1
has "key1" passphrasekey2
has "key2" passphraseSee new output "Running: ssh-add key1", "Running: ssh-add key2":
ddev auth ssh
silently pulled the image (when there was no such image), which was wrong. Now it shows the actual pull:Automated Testing Overview
Release/Deployment Notes