Skip to content

Commit 8df29fd

Browse files
committed
fixed key
1 parent 4185003 commit 8df29fd

File tree

1 file changed

+19
-5
lines changed

1 file changed

+19
-5
lines changed

.github/workflows/release.yml

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -116,19 +116,33 @@ jobs:
116116
curl -L -o plink.exe https://the.earth.li/~sgtatham/putty/latest/w64/plink.exe
117117
fi
118118
119-
# Fetch the host key using ssh-keyscan (Git Bash is available on Windows runners)
120-
ssh-keyscan -t rsa "$SFTP_HOST" > hostkey.txt 2>/dev/null
119+
# Fetch all host keys using ssh-keyscan (Git Bash is available on Windows runners)
120+
ssh-keyscan "$SFTP_HOST" > hostkey.txt 2>/dev/null
121121
122122
# Check if hostkey.txt is not empty
123123
if [ ! -s hostkey.txt ]; then
124124
echo "ERROR: ssh-keyscan failed to fetch host key for $SFTP_HOST"
125125
exit 1
126126
fi
127127
128-
# Extract the fingerprint in the format PuTTY expects (SHA256)
129-
FINGERPRINT=$(ssh-keygen -l -f hostkey.txt | grep RSA | awk '{print $2}')
128+
# Find the key type actually used by the server (prefer ed25519, then ecdsa, then rsa)
129+
KEYLINE=$(head -n 1 hostkey.txt)
130+
if echo "$KEYLINE" | grep -q 'ssh-ed25519'; then
131+
KEYTYPE="ed25519"
132+
elif echo "$KEYLINE" | grep -q 'ecdsa'; then
133+
KEYTYPE="ecdsa"
134+
elif echo "$KEYLINE" | grep -q 'ssh-rsa'; then
135+
KEYTYPE="rsa"
136+
else
137+
echo "ERROR: Unknown key type in hostkey.txt: $KEYLINE"
138+
cat hostkey.txt
139+
exit 1
140+
fi
141+
142+
# Extract the fingerprint for the detected key type
143+
FINGERPRINT=$(ssh-keygen -l -f hostkey.txt | grep -i "$KEYTYPE" | awk '{print $2}')
130144
if [ -z "$FINGERPRINT" ]; then
131-
echo "ERROR: Could not extract fingerprint from hostkey.txt"
145+
echo "ERROR: Could not extract fingerprint for $KEYTYPE from hostkey.txt"
132146
cat hostkey.txt
133147
exit 1
134148
fi

0 commit comments

Comments
 (0)