This repository has been archived by the owner on Feb 17, 2023. It is now read-only.
forked from camptocamp/build-debian-cloud
-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #79 from andsens/ecdsa-fix
Shred ECDSA keys when bootstrapping, regenerate at 1st boot
- Loading branch information
Showing
7 changed files
with
56 additions
and
8 deletions.
There are no files selected for viewing
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
#!/bin/sh | ||
### BEGIN INIT INFO | ||
# Provides: generate-ssh-hostkeys | ||
# Required-Start: $local_fs | ||
# Required-Stop: | ||
# Should-Start: | ||
# Should-Stop: | ||
# Default-Start: S | ||
# Default-Stop: | ||
# Description: Generate ssh host keys if they do not exist | ||
### END INIT INFO | ||
|
||
prog=$(basename $0) | ||
logger="logger -t $prog" | ||
|
||
rsa_key="/etc/ssh/ssh_host_rsa_key" | ||
dsa_key="/etc/ssh/ssh_host_dsa_key" | ||
ecdsa_key="/etc/ssh/ssh_host_ecdsa_key" | ||
|
||
# Exit if the hostkeys already exist | ||
if [ -f $rsa_key -a -f $dsa_key -a -f $ecdsa_key ]; then | ||
exit | ||
fi | ||
|
||
# Generate the ssh host keys | ||
[ -f $rsa_key ] || ssh-keygen -f $rsa_key -t rsa -C 'host' -N '' | ||
[ -f $dsa_key ] || ssh-keygen -f $dsa_key -t dsa -C 'host' -N '' | ||
[ -f $ecdsa_key ] || ssh-keygen -f $ecdsa_key -t ecdsa -C 'host' -N '' | ||
|
||
# Output the public keys to the console | ||
# This allows user to get host keys securely through console log | ||
echo "-----BEGIN SSH HOST KEY FINGERPRINTS-----" | $logger | ||
ssh-keygen -l -f $rsa_key.pub | $logger | ||
ssh-keygen -l -f $dsa_key.pub | $logger | ||
ssh-keygen -l -f $ecdsa_key.pub | $logger | ||
echo "------END SSH HOST KEY FINGERPRINTS------" | $logger |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#!/bin/bash | ||
# Add standard startup scripts to the init_scripts list | ||
init_scripts+=("$scriptdir/init.d/squeeze/generate-ssh-hostkeys") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#!/bin/bash | ||
# Remove the ssh host keys, they need to be shredded | ||
shred --remove \ | ||
$imagedir/etc/ssh/ssh_host_dsa_key \ | ||
$imagedir/etc/ssh/ssh_host_dsa_key.pub \ | ||
$imagedir/etc/ssh/ssh_host_rsa_key \ | ||
$imagedir/etc/ssh/ssh_host_rsa_key.pub |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
#!/bin/bash | ||
# Add standard startup scripts to the init_scripts list | ||
init_scripts+=("$scriptdir/init.d/generate-ssh-hostkeys") | ||
init_scripts+=("$scriptdir/init.d/wheezy/generate-ssh-hostkeys") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#!/bin/bash | ||
# Remove the ssh host keys, they need to be shredded | ||
shred --remove \ | ||
$imagedir/etc/ssh/ssh_host_dsa_key \ | ||
$imagedir/etc/ssh/ssh_host_dsa_key.pub \ | ||
$imagedir/etc/ssh/ssh_host_rsa_key \ | ||
$imagedir/etc/ssh/ssh_host_rsa_key.pub \ | ||
$imagedir/etc/ssh/ssh_host_ecdsa_key \ | ||
$imagedir/etc/ssh/ssh_host_ecdsa_key.pub |