Skip to content

Commit

Permalink
RHEL/CentOS 7.x has added a new ssh host key (ssh_host_ed25519_key)
Browse files Browse the repository at this point in the history
  • Loading branch information
Greg Bruno committed Jun 25, 2015
1 parent f92aefd commit 55dfd5f
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 15 deletions.
24 changes: 18 additions & 6 deletions nodes/ssh-client.xml
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ UseDNS no
<post cond="'&release;' == '6.x'">

key="
<eval cond="'&release;' == '6.x'">
<eval>
/opt/stack/sbin/read-ssh-private-key RSA1 | python -c '
import base64
import sys
Expand All @@ -82,19 +82,19 @@ base64.decode(sys.stdin, sys.stdout)' > /etc/ssh/ssh_host_key
chmod 0400 /etc/ssh/ssh_host_key

<file name="/etc/ssh/ssh_host_key.pub" perms="0444">
<eval cond="'&release;' == '6.x'">
<eval>
cat /etc/ssh/ssh_host_key.pub
</eval>
</file>

<file name="/etc/ssh/ssh_host_dsa_key" perms="0400">
<eval cond="'&release;' == '6.x'">
<eval>
/opt/stack/sbin/read-ssh-private-key DSA
</eval>
</file>

<file name="/etc/ssh/ssh_host_dsa_key.pub" perms="0444">
<eval cond="'&release;' == '6.x'">
<eval>
cat /etc/ssh/ssh_host_dsa_key.pub
</eval>
</file>
Expand All @@ -105,17 +105,29 @@ cat /etc/ssh/ssh_host_dsa_key.pub
<post cond="'&release;' == '7.x'">

<file name="/etc/ssh/ssh_host_ecdsa_key" perms="0400">
<eval cond="'&release;' == '7.x'">
<eval>
/opt/stack/sbin/read-ssh-private-key ECDSA
</eval>
</file>

<file name="/etc/ssh/ssh_host_ecdsa_key.pub" perms="0444">
<eval cond="'&release;' == '7.x'">
<eval>
cat /etc/ssh/ssh_host_ecdsa_key.pub
</eval>
</file>

<file name="/etc/ssh/ssh_host_ed25519_key" perms="0400">
<eval>
/opt/stack/sbin/read-ssh-private-key ED25519
</eval>
</file>

<file name="/etc/ssh/ssh_host_ed25519_key.pub" perms="0444">
<eval>
cat /etc/ssh/ssh_host_ed25519_key.pub
</eval>
</file>

</post>


Expand Down
4 changes: 1 addition & 3 deletions nodes/ssh-server.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,7 @@ All rights reserved. stacki(r) v1.0 www.stacki.com

<post>
<!-- clean up ssh_host* files. They will be recreated on first boot -->
rm -f /etc/ssh/ssh_host_dsa_key*
rm -f /etc/ssh/ssh_host_rsa_key*
rm -f /etc/ssh/ssh_host_key*
rm -f /etc/ssh/ssh_host_*
</post>


Expand Down
17 changes: 11 additions & 6 deletions src/stack/kickstart/utils/read-ssh-private-key.c
Original file line number Diff line number Diff line change
Expand Up @@ -134,10 +134,11 @@ static char rcsid[] = "$Id$";
#define MYUSER "apache"

/* The different kinds of keys. */
#define RSA1 1
#define RSA 2
#define DSA 3
#define ECDSA 4
#define RSA1 1
#define RSA 2
#define DSA 3
#define ECDSA 4
#define ED25519 5

int
main(int argc, char *argv[])
Expand Down Expand Up @@ -170,6 +171,8 @@ main(int argc, char *argv[])
mode = DSA;
else if (!strncmp("ECDSA", argv[1], 5))
mode = ECDSA;
else if (!strncmp("ED25519", argv[1], 5))
mode = ED25519;
}

switch (mode)
Expand All @@ -186,9 +189,11 @@ main(int argc, char *argv[])
case ECDSA:
keyfile = FILENAME "/ssh_host_ecdsa_key";
break;
case ED25519:
keyfile = FILENAME "/ssh_host_ed25519_key";
break;
default:
fprintf(stderr,
"Please specify a key: RSA1 | RSA | DSA | ECDSA\n");
fprintf(stderr, "Please specify a key: RSA1 | RSA | DSA | ECDSA | ED25519\n");
return 1;
}

Expand Down

0 comments on commit 55dfd5f

Please sign in to comment.