Skip to content

Commit f6ec37a

Browse files
authored
Merge pull request #35 from duynd0909/dev
fix: strip SSH key passphrase before use in deploy
2 parents c6c7f13 + b65211e commit f6ec37a

1 file changed

Lines changed: 5 additions & 10 deletions

File tree

.github/workflows/deploy.yml

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -91,19 +91,14 @@ jobs:
9191
echo "${{ secrets.DEPLOY_SSH_KEY }}" > ~/.ssh/deploy_key
9292
chmod 600 ~/.ssh/deploy_key
9393
94-
# Create askpass script so ssh can provide the passphrase non-interactively
95-
cat > ~/.ssh/askpass.sh << 'ASKPASS'
96-
#!/bin/sh
97-
echo "$SSH_PASS"
98-
ASKPASS
99-
chmod +x ~/.ssh/askpass.sh
94+
# Strip passphrase so ssh doesn't need askpass
95+
cp ~/.ssh/deploy_key ~/.ssh/deploy_key.locked
96+
ssh-keygen -p -f ~/.ssh/deploy_key.locked -P "$SSH_PASS" -N "" -q
97+
mv ~/.ssh/deploy_key.locked ~/.ssh/deploy_key
10098
10199
- name: Deploy via SSH
102-
env:
103-
SSH_ASKPASS: ~/.ssh/askpass.sh
104-
SSH_ASKPASS_REQUIRE: force
105100
run: |
106-
ssh -o StrictHostKeyChecking=no -i ~/.ssh/deploy_key -p ${{ secrets.DEPLOY_PORT }} ${{ secrets.DEPLOY_USER }}@${{ secrets.DEPLOY_HOST }} << 'DEPLOY'
101+
ssh -T -o StrictHostKeyChecking=no -i ~/.ssh/deploy_key -p ${{ secrets.DEPLOY_PORT }} ${{ secrets.DEPLOY_USER }}@${{ secrets.DEPLOY_HOST }} << 'DEPLOY'
107102
cd ${{ secrets.DEPLOY_PATH }}
108103
109104
# Pull latest images

0 commit comments

Comments
 (0)