@@ -208,7 +208,64 @@ jobs:
208208 run : |
209209 command -v advzip || { sudo apt-get update && sudo apt-get install -y advancecomp; }
210210
211+ - name : Set up SSH key
212+ env :
213+ GREENGEEKS_HOST : ${{ vars.GREENGEEKS_SSH_HOST }}
214+ GREENGEEKS_KEY : ${{ secrets.GREENGEEKS_SSH_PRIVATE_KEY }}
215+ GREENGEEKS_USER : ${{ vars.GREENGEEKS_SSH_USER }}
216+ run : |
217+ mkdir -p ~/.ssh
218+ if [ -z "$GREENGEEKS_HOST" ]; then
219+ echo "Error: SSH_HOST variable is not set"
220+ exit 1
221+ fi
222+ # Write the SSH key, ensuring proper formatting
223+ echo "$GREENGEEKS_KEY" > ~/.ssh/id_rsa
224+ # Remove any trailing newlines and ensure proper key format
225+ sed -i '' -e '$ { /^$/ d; }' ~/.ssh/id_rsa 2>/dev/null || sed -i '$ { /^$/ d; }' ~/.ssh/id_rsa
226+ chmod 600 ~/.ssh/id_rsa
227+ # Verify key format
228+ if ! grep -q "BEGIN.*PRIVATE KEY" ~/.ssh/id_rsa; then
229+ echo "Error: SSH key does not appear to be in correct format"
230+ exit 1
231+ fi
232+ # Configure SSH to use only the key file and disable other auth methods
233+ cat > ~/.ssh/config <<EOF
234+ Host *
235+ IdentitiesOnly yes
236+ PreferredAuthentications publickey
237+ StrictHostKeyChecking no
238+ UserKnownHostsFile ~/.ssh/known_hosts
239+ PubkeyAuthentication yes
240+ PasswordAuthentication no
241+ ChallengeResponseAuthentication no
242+ GSSAPIAuthentication no
243+ GSSAPIKeyExchange no
244+ GSSAPIDelegateCredentials no
245+ Host $GREENGEEKS_HOST
246+ User $GREENGEEKS_USER
247+ IdentityFile ~/.ssh/id_rsa
248+ IdentitiesOnly yes
249+ PreferredAuthentications publickey
250+ PubkeyAuthentication yes
251+ PasswordAuthentication no
252+ ChallengeResponseAuthentication no
253+ GSSAPIAuthentication no
254+ GSSAPIKeyExchange no
255+ GSSAPIDelegateCredentials no
256+ NumberOfPasswordPrompts 0
257+ EOF
258+ chmod 600 ~/.ssh/config
259+ # Disable SSH agent completely
260+ unset SSH_AUTH_SOCK
261+ unset SSH_AGENT_PID
262+ # Remove any default SSH keys that might interfere
263+ rm -f ~/.ssh/id_ed25519 ~/.ssh/id_ecdsa ~/.ssh/id_dsa ~/.ssh/id_rsa.pub 2>/dev/null
264+ ssh-keyscan -H "$GREENGEEKS_HOST" >> ~/.ssh/known_hosts 2>/dev/null
265+
211266 - name : Download release assets
267+ env :
268+ SCP_HOST : ${{ vars.GREENGEEKS_SSH_HOST }}
212269 run : |
213270 flox activate -d flox/base -- ./gradlew :app:assetsDownloadRelease --no-daemon
214271
0 commit comments