Skip to content

Commit

Permalink
Improve the ssh-askpass.sh script (#453)
Browse files Browse the repository at this point in the history
Do the default vscode flow (get the passphrase from the inputbox) under next conditions:
If the passphrase file is missing.
If the passphrase is incorrect, for that we test the passphrase with the ssh-keygen.
  • Loading branch information
vinokurig authored Nov 18, 2024
1 parent 7f5c443 commit 3d2e031
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 4 deletions.
6 changes: 6 additions & 0 deletions .rebase/replace/code/extensions/git/src/ssh-askpass.sh.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[
{
"from": "#!/bin/sh",
"by": "#!/bin/sh\\\nif [ -f /etc/ssh/passphrase ] && command -v ssh-keygen >/dev/null; then\\\n\\\tif ssh-keygen -y -P \"$(cat /etc/ssh/passphrase)\" -f /etc/ssh/dwo_ssh_key >/dev/null; then\\\n\\\t\\\tcat /etc/ssh/passphrase\\\n\\\t\\\texit 0\\\n\\\tfi\\\nfi"
}
]
12 changes: 10 additions & 2 deletions code/extensions/git/src/ssh-askpass.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
#!/bin/sh
# see https://github.com/devfile/devworkspace-operator/blob/main/docs/additional-configuration.adoc#configuring-devworkspaces-to-use-ssh-keys-for-git-operations
cat /etc/ssh/passphrase
if [ -f /etc/ssh/passphrase ] && command -v ssh-keygen >/dev/null; then
if ssh-keygen -y -P "$(cat /etc/ssh/passphrase)" -f /etc/ssh/dwo_ssh_key >/dev/null; then
cat /etc/ssh/passphrase
exit 0
fi
fi
VSCODE_GIT_ASKPASS_PIPE=`mktemp`
ELECTRON_RUN_AS_NODE="1" VSCODE_GIT_ASKPASS_PIPE="$VSCODE_GIT_ASKPASS_PIPE" VSCODE_GIT_ASKPASS_TYPE="ssh" "$VSCODE_GIT_ASKPASS_NODE" "$VSCODE_GIT_ASKPASS_MAIN" $VSCODE_GIT_ASKPASS_EXTRA_ARGS $*
cat $VSCODE_GIT_ASKPASS_PIPE
rm $VSCODE_GIT_ASKPASS_PIPE
7 changes: 5 additions & 2 deletions rebase.sh
Original file line number Diff line number Diff line change
Expand Up @@ -316,8 +316,11 @@ apply_code_src_vs_code_browser_workbench_workbench_changes() {
apply_code_extensions_git_src_ssh-askpass_changes() {

echo " ⚙️ reworking code/extensions/git/src/ssh-askpass.sh..."
# reset the file from local
git checkout --ours code/extensions/git/src/ssh-askpass.sh > /dev/null 2>&1
# reset the file from upstream
git checkout --theirs code/extensions/git/src/ssh-askpass.sh > /dev/null 2>&1

# apply the changes
apply_replace code/extensions/git/src/ssh-askpass.sh

# resolve the change
git add code/extensions/git/src/ssh-askpass.sh > /dev/null 2>&1
Expand Down

0 comments on commit 3d2e031

Please sign in to comment.