Skip to content

Commit

Permalink
Have dropbear put SSH server keys in /tmp/userdata/etc/dropbear so th…
Browse files Browse the repository at this point in the history
…ey persist

This will cause the keys to persist across firmware updates and works regardless of whether you have data on sdcard or internal storage.
There is still a fallback, the S10setup script still makes keys in /etc/dropbear so if something is wrong with /root still will start SSH
  • Loading branch information
toys4me committed Feb 23, 2013
1 parent 5b50126 commit 27b88b4
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions package/dropbear/S50dropbear
Original file line number Diff line number Diff line change
Expand Up @@ -9,28 +9,28 @@
start() {
echo -n "Starting dropbear sshd: "
# Make sure dropbear directory exists
if [ ! -d /etc/dropbear ] ; then
mkdir -p /etc/dropbear
if [ ! -d /tmp/userdata/etc/dropbear ] ; then
mkdir -p /tmp/userdata/etc/dropbear
fi
# Check for the Dropbear RSA key
if [ ! -f /etc/dropbear/dropbear_rsa_host_key ] ; then
if [ ! -f /tmp/userdata/etc/dropbear/dropbear_rsa_host_key ] ; then
echo -n "generating rsa key... "
/usr/bin/dropbearkey -t rsa -f /etc/dropbear/dropbear_rsa_host_key > /dev/null 2>&1
/usr/bin/dropbearkey -t rsa -f /tmp/userdata/etc/dropbear/dropbear_rsa_host_key > /dev/null 2>&1
fi

# Check for the Dropbear DSS key
if [ ! -f /etc/dropbear/dropbear_dss_host_key ] ; then
if [ ! -f /tmp/userdata/etc/dropbear/dropbear_dss_host_key ] ; then
echo -n "generating dsa key... "
/usr/bin/dropbearkey -t dss -f /etc/dropbear/dropbear_dss_host_key > /dev/null 2>&1
/usr/bin/dropbearkey -t dss -f /tmp/userdata/etc/dropbear/dropbear_dss_host_key > /dev/null 2>&1
fi

# If one or more keys exist on SDCard, use that instead
HOSTKEYS=""
if [ -f /media/sdcard/xbmc-data/etc/dropbear/dropbear_dss_host_key ]; then
HOSTKEYS=" -d /media/sdcard/xbmc-data/etc/dropbear/dropbear_dss_host_key"
if [ -f /tmp/userdata/etc/dropbear/dropbear_dss_host_key ]; then
HOSTKEYS=" -d /tmp/userdata/etc/dropbear/dropbear_dss_host_key"
fi
if [ -f /media/sdcard/xbmc-data/etc/dropbear/dropbear_rsa_host_key ]; then
HOSTKEYS="$HOSTKEYS -r /media/sdcard/xbmc-data/etc/dropbear/dropbear_rsa_host_key"
if [ -f /tmp/userdata/etc/dropbear/dropbear_rsa_host_key ]; then
HOSTKEYS="$HOSTKEYS -r /tmp/userdata/etc/dropbear/dropbear_rsa_host_key"
fi

umask 077
Expand Down

0 comments on commit 27b88b4

Please sign in to comment.