Skip to contentSkip to conversation

package/dropbear: add warning about volatile keys

PATCH New Yann E. MORIN 2 participants 5 messages Aug 25, 2015 – Aug 30, 2015

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 package/dropbear: add warning about volatile keys

When the rootfs is read-only, keys will be generated in a volatile location, which is inherently bad as host keys will change on each boot, rendering virtually useless.

Add a warning so the user is at least aware of the issue.

Consign the rm output to oblivion, to avoid noisy output, now that we have a proper warning.

Move the starting message after the symlink-block, to avoid messages collision. Move the umask as well, sicne /etc/dropbear/ may be world readable; just the private host keys should be ?00 (and dropbear handles that by itself).

---
 package/dropbear/S50dropbear      | 12 +++++++-----
 package/dropbear/dropbear.service |  6 ++++--
 2 files changed, 11 insertions(+), 7 deletions(-)
package/dropbear/S50dropbear +7 -5
index 765d6a3..b4e3c5c 100644
@@ -9,9 +9,6 @@ test -r /etc/default/dropbear && . /etc/default/dropbear
 start() {
 	DROPBEAR_ARGS="$DROPBEAR_ARGS -R"
 
-	echo -n "Starting dropbear sshd: "
-	umask 077
-
 	# If /etc/dropbear is a symlink to /var/run/dropbear, and
 	#   - the filesystem is RO (i.e. we can not rm the symlink),
 	#     create the directory pointed to by the symlink.
@@ -20,13 +17,18 @@ start() {
 	if [ -L /etc/dropbear \
 	     -a "$(readlink /etc/dropbear)" = "/var/run/dropbear" ]
 	then
-		if rm -f /etc/dropbear; then
+		if rm -f /etc/dropbear >/dev/null 2>&1; then
 			mkdir -p /etc/dropbear
 		else
-			mkdir -p $(readlink /etc/dropbear)
+			echo "No persistent location to store SSH host keys. New keys will be"
+			echo "generated at each boot. Are you sure this is what you want to do?"
+			mkdir -p "$(readlink /etc/dropbear)"
 		fi
 	fi
 
+	echo -n "Starting dropbear sshd: "
+	umask 077
+
 	start-stop-daemon -S -q -p /var/run/dropbear.pid \
 		--exec /usr/sbin/dropbear -- $DROPBEAR_ARGS
 	[ $? = 0 ] && echo "OK" || echo "FAIL"
package/dropbear/dropbear.service +4 -2
index 9dcbf25..1eb42f9 100644
@@ -11,10 +11,12 @@ After=syslog.target network.target auditd.service
 ExecStartPre=/bin/sh -c '\
 if [ -L /etc/dropbear \
      -a "$(readlink /etc/dropbear)" = "/var/run/dropbear" ]; then \
-    if rm -f /etc/dropbear; then \
+    if rm -f /etc/dropbear >/dev/null 2>&1; then \
         mkdir -p /etc/dropbear; \
     else \
-        mkdir -p $(readlink /etc/dropbear); \
+        echo "No persistent location to store SSH host keys. New keys will be"; \
+        echo "generated at each boot. Are you sure this is what you want to do?"; \
+        mkdir -p "$(readlink /etc/dropbear)"; \
     fi; \
 fi'
 ExecStart=/usr/sbin/dropbear -F -R
Signature · 1 line
1.9.1
#1 lore raw

PATCH 1/1 package/dropbear: add warning about volatile keys

Quoted 5 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"Yann" == Yann E MORIN <[email protected]> writes:

When the rootfs is read-only, keys will be generated in a volatile location, which is inherently bad as host keys will change on each boot, rendering virtually useless.

+them

Quoted 4 lines

Add a warning so the user is at least aware of the issue.

Consign the rm output to oblivion, to avoid noisy output, now that we have a proper warning.

Is consign a English word? I changed it to 'hide' as I think that is clearer.

Quoted 7 lines

Move the starting message after the symlink-block, to avoid messages collision. Move the umask as well, sicne /etc/dropbear/ may be world readable; just the private host keys should be ?00 (and dropbear handles that by itself).

Committed, thanks.

Signature · 1 line
Bye, Peter Korsgaard
#2 lore raw

PATCH 1/1 package/dropbear: add warning about volatile keys

Peter, All,

On 2015-08-30 22:05 +0200, Peter Korsgaard spake thusly:

Quoted 6 lines
Quoted 5 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"Yann" == Yann E MORIN <[email protected]> writes:

When the rootfs is read-only, keys will be generated in a volatile location, which is inherently bad as host keys will change on each boot, rendering virtually useless.

+them

Ack.

Quoted 6 lines
Quoted 4 lines

Add a warning so the user is at least aware of the issue.

Consign the rm output to oblivion, to avoid noisy output, now that we have a proper warning.

Is consign a English word? I changed it to 'hide' as I think that is clearer.

Yes, it is:
http://www.merriam-webster.com/dictionary/consign

to put (something that is not wanted or used) in a place where old things are stored or thrown away

Regards,
Yann E. MORIN.

Signature · 6 lines
.-----------------.--------------------.------------------.--------------------.
|  Yann E. MORIN  | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software  Designer | \ / CAMPAIGN     |  ___               |
| +33 223 225 172 `------------.-------:  X  AGAINST      |  \e/  There is no  |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL    |   v   conspiracy.  |
'------------------------------^-------^------------------^--------------------'
#3 lore raw

PATCH 1/1 package/dropbear: add warning about volatile keys

Peter, All,

On 2015-08-30 22:12 +0200, Yann E. MORIN spake thusly:

Quoted 5 lines

On 2015-08-30 22:05 +0200, Peter Korsgaard spake thusly:

Quoted 4 lines
Quoted 3 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"Yann" == Yann E MORIN <[email protected]> writes:

Consign the rm output to oblivion, to avoid noisy output, now that we have a proper warning.

Quoted 7 lines
Quoted 1 line

Is consign a English word? I changed it to 'hide' as I think that is clearer.

Yes, it is:
http://www.merriam-webster.com/dictionary/consign

to put (something that is not wanted or used) in a place where old things are stored or thrown away

Or even better yet:

to commit especially to a final destination or fate <a writer consigned to oblivion>

Muhahaha! ;-)

Regards,
Yann E. MORIN.

Signature · 6 lines
.-----------------.--------------------.------------------.--------------------.
|  Yann E. MORIN  | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software  Designer | \ / CAMPAIGN     |  ___               |
| +33 223 225 172 `------------.-------:  X  AGAINST      |  \e/  There is no  |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL    |   v   conspiracy.  |
'------------------------------^-------^------------------^--------------------'
#4 lore raw

PATCH 1/1 package/dropbear: add warning about volatile keys

In reply to Yann E. MORIN
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"Yann" == Yann E MORIN <[email protected]> writes:

Hi,

Quoted 7 lines
Quoted 4 lines
Quoted 2 lines

Consign the rm output to oblivion, to avoid noisy output, now that we have a proper warning.

Is consign a English word? I changed it to 'hide' as I think that is clearer.

Yes, it is:
http://www.merriam-webster.com/dictionary/consign

Ok, thanks ;)

Signature · 2 lines
Venlig hilsen,
Peter Korsgaard