mirror of
https://github.com/kernelkit/infix.git
synced 2026-07-30 12:33:02 +02:00
Merge pull request #1290 from kernelkit/hostkey-warning
Fix SSH host key generation warnings
This commit is contained in:
@@ -8,7 +8,8 @@ PUB=$2
|
|||||||
|
|
||||||
mkdir -p "$(dirname "$KEY")" "$(dirname "$PUB")"
|
mkdir -p "$(dirname "$KEY")" "$(dirname "$PUB")"
|
||||||
|
|
||||||
|
# openssl genpkey -quiet -algorithm EC -pkeyopt ec_paramgen_curve:P-256 -outform PEM
|
||||||
openssl genpkey -quiet -algorithm RSA -pkeyopt rsa_keygen_bits:$BIT -outform PEM > "$KEY"
|
openssl genpkey -quiet -algorithm RSA -pkeyopt rsa_keygen_bits:$BIT -outform PEM > "$KEY"
|
||||||
openssl rsa -RSAPublicKey_out < "$KEY" > "$PUB"
|
openssl rsa -RSAPublicKey_out < "$KEY" 2>/dev/null > "$PUB"
|
||||||
|
|
||||||
exit 0
|
exit 0
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
#!/bin/bash
|
#!/bin/sh
|
||||||
# Store and convert RSA PUBLIC/PRIVATE KEYs to be able to use them in
|
# Generate OpenSSH host key pair from same keys as NETCONF
|
||||||
# OpenSSHd.
|
|
||||||
set -e
|
set -e
|
||||||
|
umask 0077
|
||||||
|
|
||||||
NAME="$1"
|
NAME="$1"
|
||||||
DIR="$2"
|
DIR="$2"
|
||||||
@@ -9,16 +9,21 @@ PUBLIC="$3"
|
|||||||
PRIVATE="$4"
|
PRIVATE="$4"
|
||||||
TMP="$(mktemp)"
|
TMP="$(mktemp)"
|
||||||
|
|
||||||
echo -e '-----BEGIN RSA PRIVATE KEY-----' > "$DIR/$NAME"
|
{
|
||||||
echo "$PRIVATE" >> "$DIR/$NAME"
|
echo '-----BEGIN PRIVATE KEY-----'
|
||||||
echo -e '-----END RSA PRIVATE KEY-----' >> "$DIR/$NAME"
|
printf '%s\n' "$PRIVATE" | fold -w 64
|
||||||
|
echo '-----END PRIVATE KEY-----'
|
||||||
|
} > "$DIR/$NAME"
|
||||||
|
|
||||||
echo -e "-----BEGIN RSA PUBLIC KEY-----" > "$TMP"
|
{
|
||||||
echo -e "$PUBLIC" >> "$TMP"
|
echo "-----BEGIN RSA PUBLIC KEY-----"
|
||||||
echo -e "-----END RSA PUBLIC KEY-----" >> "$TMP"
|
printf '%s\n' "$PUBLIC" | fold -w 64
|
||||||
|
echo "-----END RSA PUBLIC KEY-----"
|
||||||
|
} > "$TMP"
|
||||||
|
|
||||||
ssh-keygen -i -m PKCS8 -f "$TMP" > "$DIR/$NAME.pub"
|
ssh-keygen -i -f "$TMP" -m PKCS8 > "$DIR/$NAME.pub"
|
||||||
rm "$TMP"
|
rm "$TMP"
|
||||||
|
|
||||||
chmod 0600 "$DIR/$NAME.pub"
|
chmod 0600 "$DIR/$NAME.pub"
|
||||||
chmod 0600 "$DIR/$NAME"
|
chmod 0600 "$DIR/$NAME"
|
||||||
chown sshd:sshd "$DIR/$NAME.pub"
|
chown sshd:sshd "$DIR/$NAME.pub"
|
||||||
|
|||||||
+2
-1
@@ -3,7 +3,7 @@ Change Log
|
|||||||
|
|
||||||
All notable changes to the project are documented in this file.
|
All notable changes to the project are documented in this file.
|
||||||
|
|
||||||
[v25.11.0][] - 2025-11-28
|
[v25.11.0][UNRELEASED]
|
||||||
-------------------------
|
-------------------------
|
||||||
|
|
||||||
> [!NOTE]
|
> [!NOTE]
|
||||||
@@ -82,6 +82,7 @@ All notable changes to the project are documented in this file.
|
|||||||
existing invalid configurations are automatically corrected during upgrade
|
existing invalid configurations are automatically corrected during upgrade
|
||||||
- Fix #1255: serious regression in boot time, introduced in v25.10, delays the
|
- Fix #1255: serious regression in boot time, introduced in v25.10, delays the
|
||||||
boot step "Mounting filesystems ...", from 30 seconds up to five minutes!
|
boot step "Mounting filesystems ...", from 30 seconds up to five minutes!
|
||||||
|
- Fix #1289: SSH host key generation warning at boot after factory reset
|
||||||
- Fix broken intra-document links in container and tunnel documentation
|
- Fix broken intra-document links in container and tunnel documentation
|
||||||
- Fix `show dhcp-server` command crashing with invalid timestamp format.
|
- Fix `show dhcp-server` command crashing with invalid timestamp format.
|
||||||
DHCP lease expiry timestamps had double timezone suffix causing libyang
|
DHCP lease expiry timestamps had double timezone suffix causing libyang
|
||||||
|
|||||||
@@ -59,12 +59,17 @@ static int gen_hostkey(const char *name, struct lyd_node *change)
|
|||||||
private_key = lydx_get_cattr(change, "cleartext-private-key");
|
private_key = lydx_get_cattr(change, "cleartext-private-key");
|
||||||
public_key = lydx_get_cattr(change, "public-key");
|
public_key = lydx_get_cattr(change, "public-key");
|
||||||
|
|
||||||
|
/* Validate keys before use */
|
||||||
|
if (!private_key || !public_key || !*private_key || !*public_key)
|
||||||
|
return SR_ERR_OK;
|
||||||
|
|
||||||
if (mkdir(SSH_HOSTKEYS_NEXT, 0600) && (errno != EEXIST)) {
|
if (mkdir(SSH_HOSTKEYS_NEXT, 0600) && (errno != EEXIST)) {
|
||||||
ERRNO("Failed creating %s", SSH_HOSTKEYS_NEXT);
|
ERRNO("Failed creating %s", SSH_HOSTKEYS_NEXT);
|
||||||
rc = SR_ERR_INTERNAL;
|
rc = SR_ERR_INTERNAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (systemf("/usr/libexec/infix/mksshkey %s %s %s %s", name, SSH_HOSTKEYS_NEXT, public_key, private_key))
|
if (systemf("/usr/libexec/infix/mksshkey %s %s %s %s", name,
|
||||||
|
SSH_HOSTKEYS_NEXT, public_key, private_key))
|
||||||
rc = SR_ERR_INTERNAL;
|
rc = SR_ERR_INTERNAL;
|
||||||
|
|
||||||
return rc;
|
return rc;
|
||||||
@@ -156,7 +161,7 @@ static int keystore_update(sr_session_ctx_t *session, struct lyd_node *config, s
|
|||||||
}
|
}
|
||||||
|
|
||||||
int keystore_change(sr_session_ctx_t *session, struct lyd_node *config, struct lyd_node *diff,
|
int keystore_change(sr_session_ctx_t *session, struct lyd_node *config, struct lyd_node *diff,
|
||||||
sr_event_t event, struct confd *confd)
|
sr_event_t event, struct confd *confd)
|
||||||
{
|
{
|
||||||
struct lyd_node *changes, *change;
|
struct lyd_node *changes, *change;
|
||||||
int rc = SR_ERR_OK;
|
int rc = SR_ERR_OK;
|
||||||
|
|||||||
Reference in New Issue
Block a user