File tree Expand file tree Collapse file tree 1 file changed +19
-5
lines changed Expand file tree Collapse file tree 1 file changed +19
-5
lines changed Original file line number Diff line number Diff line change @@ -116,19 +116,33 @@ jobs:
116
116
curl -L -o plink.exe https://the.earth.li/~sgtatham/putty/latest/w64/plink.exe
117
117
fi
118
118
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
121
121
122
122
# Check if hostkey.txt is not empty
123
123
if [ ! -s hostkey.txt ]; then
124
124
echo "ERROR: ssh-keyscan failed to fetch host key for $SFTP_HOST"
125
125
exit 1
126
126
fi
127
127
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}')
130
144
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"
132
146
cat hostkey.txt
133
147
exit 1
134
148
fi
You can’t perform that action at this time.
0 commit comments