Skip to content

Commit

Permalink
Merge pull request #45 from tinez/dropbear-init-fix
Browse files Browse the repository at this point in the history
Fix dropbear init if /etc/dropbear is a symlink
  • Loading branch information
smoser authored Mar 3, 2020
2 parents 690be2b + d3c0f0a commit 1548dfa
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions src/etc/init.d/S50dropbear
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,21 @@ start() {

echo -n "Starting dropbear sshd: "
umask 077
# Ensure host keys are changed when instance ID changes
cirros-per instance remove-dropbear-host-keys -- rm -rf /etc/dropbear

# Make sure dropbear directory exists
if [ ! -d /etc/dropbear ]; then
mkdir -p /etc/dropbear
local dropbear_key_dir="/etc/dropbear"

# Handle symlinked directories
if [ -L "$dropbear_key_dir" ]; then
dropbear_key_dir=$(readlink -f "$dropbear_key_dir")
fi

# Ensure host keys are changed when instance ID changes
cirros-per instance remove-dropbear-host-keys -- rm -rf "$dropbear_key_dir"
mkdir -p "$dropbear_key_dir"

# Regenerate invalid or missing keys
local ktype file
for ktype in rsa ecdsa; do
file="/etc/dropbear/dropbear_${ktype}_host_key"
file="${dropbear_key_dir}/dropbear_${ktype}_host_key"
# -f = input file, -y = validate and print pubkey info
if ! dropbearkey -f "$file" -y &>/dev/null; then
if [ -e "$file" ]; then
Expand Down

0 comments on commit 1548dfa

Please sign in to comment.