File tree Expand file tree Collapse file tree 1 file changed +10
-11
lines changed
Expand file tree Collapse file tree 1 file changed +10
-11
lines changed Original file line number Diff line number Diff line change @@ -127,21 +127,20 @@ jobs:
127127
128128
129129
130- # Find the first non-comment line (actual key) in hostkey.txt
131- KEYLINE=$(grep -v '^#' hostkey.txt | head -n 1)
132- if echo "$KEYLINE" | grep -q 'ssh-ed25519' ; then
133- KEYTYPE="ssh-ed25519"
134- elif echo "$KEYLINE" | grep -q 'ecdsa'; then
135- KEYTYPE="ecdsa-sha2-nistp256"
136- elif echo "$ KEYLINE" | grep -q 'ssh-rsa'; then
137- KEYTYPE="ssh-rsa"
138- else
139- echo "ERROR: Unknown key type in hostkey.txt: $KEYLINE "
130+ # Always prefer ed25519, then ecdsa, then rsa for PuTTY host key
131+ KEYLINE=$(grep -v '^#' hostkey.txt | grep 'ssh-ed25519' | head -n 1)
132+ if [ -z "$KEYLINE" ] ; then
133+ KEYLINE=$(grep -v '^#' hostkey.txt | grep 'ecdsa' | head -n 1)
134+ fi
135+ if [ -z "$KEYLINE" ]; then
136+ KEYLINE=$(grep -v '^#' hostkey.txt | grep 'ssh-rsa' | head -n 1)
137+ fi
138+ if [ -z "$KEYLINE" ]; then
139+ echo "ERROR: Could not find a supported host key type (ed25519, ecdsa, rsa) in hostkey.txt"
140140 cat hostkey.txt
141141 exit 1
142142 fi
143143
144- # Extract the key type and base64 key, join with colon for PuTTY format
145144 KEYTYPE_FIELD=$(echo "$KEYLINE" | awk '{print $1}')
146145 KEYDATA_FIELD=$(echo "$KEYLINE" | awk '{print $2}')
147146 PUTTY_HOSTKEY="$KEYTYPE_FIELD:$KEYDATA_FIELD"
You can’t perform that action at this time.
0 commit comments