Difference between revisions of "HIP:TS-7000:dropbear"

From Earlham CS Department
Jump to navigation Jump to search
(move it to / and unpack it)
(configure/make)
 
(20 intermediate revisions by 2 users not shown)
Line 1: Line 1:
 
= about =
 
= about =
This page describes how to compile dropbear to run in Technologic System's TS-Linux distribution. We're using the TS-7260.
+
This page describes how to compile [http://matt.ucc.asn.au/dropbear/dropbear.html dropbear] to run in [http://www.embeddedarm.com/ Technologic System's] [http://www.embeddedarm.com/linux/ARM.htm TS-Linux for ARM] distribution. Debian was used for development and cross compiling. The TS-7260's root file system uses the RedBoot NFS option.
  
 
= compiling =
 
= compiling =
 
== crosstool setup ==
 
== crosstool setup ==
 
=== download and setup ts crosstool package ===
 
=== download and setup ts crosstool package ===
* At the time of this writing, I downloaded '''Linux Crosstool gcc-4.0.1-glibc-2.3.5 -- unknown (05-20-2006)'''
+
* At the time of this writing, the '''Linux Crosstool gcc-4.0.1-glibc-2.3.5 -- unknown (05-20-2006)''' was available
 
  ftp://ftp.embeddedarm.com/ts-arm-linux-cd/cross-toolchains/crosstool-linux-gcc-4.0.1-glibc-2.3.5.tar.bz2
 
  ftp://ftp.embeddedarm.com/ts-arm-linux-cd/cross-toolchains/crosstool-linux-gcc-4.0.1-glibc-2.3.5.tar.bz2
  
Line 13: Line 13:
  
 
=== add it to your path ===
 
=== add it to your path ===
  arm@crow:~$ cat ~/.bash_profile | grep cross
+
  $ cat ~/.bash_profile | grep cross
 
  PATH=/opt/crosstool/gcc-4.0.1- glibc-2.3.5/arm-unknown-linux-gnu/bin:${PATH}
 
  PATH=/opt/crosstool/gcc-4.0.1- glibc-2.3.5/arm-unknown-linux-gnu/bin:${PATH}
  
Line 24: Line 24:
 
   
 
   
  
=== configure make ===
+
=== configure/make ===
  
* dropbear needs access to a good random pool in /dev/random, otherwise it will print this message while running:
+
* dropbear needs access to a good random pool in /dev/random and for some reason it would always hang on /dev/random and would print this message while running:
  
 
  Warning: Reading the random source seems to have blocked.
 
  Warning: Reading the random source seems to have blocked.
 
  If you experience problems, you probably need to find a better entropy source.  
 
  If you experience problems, you probably need to find a better entropy source.  
  
* i edited options.h and changed the random device to be urandom for this error.
+
* so i edited options.h and changed the random device to be urandom for this error.
  
 
  #define DROPBEAR_RANDOM_DEV "/dev/urandom"
 
  #define DROPBEAR_RANDOM_DEV "/dev/urandom"
Line 37: Line 37:
 
* the shell script i used to automate the build process
 
* the shell script i used to automate the build process
  
$ cat run.sh  
+
$ cat run.sh  
 
  export CFLAGS="-Os -static -Wall"
 
  export CFLAGS="-Os -static -Wall"
 
  export LDFLAGS="-static"
 
  export LDFLAGS="-static"
  ./configure --host=arm-unknown-linux-gnu --build=arm --disable-zlib --disable-syslog
+
  ./configure --host=arm-unknown-linux-gnu --build=arm --disable-zlib --disable-syslog --disable-lastlog (optionally add --enable-static)
 
  make clean
 
  make clean
 
  make PROGRAMS="dropbear dbclient dropbearkey dropbearconvert scp" MULTI=1 STATIC=1
 
  make PROGRAMS="dropbear dbclient dropbearkey dropbearconvert scp" MULTI=1 STATIC=1
  
=== move to usr/sbin ===
+
=== move files ===
* dropbearmulti is primary binary, the rest are symbolic links to it
 
  
arm@crow:~/dropbear-0.49$ mv dropbearmulti ../tslinux/usr/sbin
+
* relocate files to nfs directory
arm@crow:~/tslinux/usr/sbin$ ln -s dropbearmulti scp
 
arm@crow:~/tslinux/usr/sbin$ ln -s dropbearmulti dropbearconvert
 
arm@crow:~/tslinux/usr/sbin$ ln -s dropbearmulti dropbearkey
 
arm@crow:~/tslinux/usr/sbin$ ln -s dropbearmulti dbclient
 
arm@crow:~/tslinux/usr/sbin$ ln -s dropbearmulti dropbear
 
  
  arm@crow:~/tslinux/usr/sbin$ ls -l | grep drop
+
  $ ln -s dropbearmulti ssh
lrwxrwxrwx 1 arm arm    13 2007-05-23 11:29 dbclient -> dropbearmulti
+
  $ mv dropbear ssh scp dropbearmulti dropbearkey dropbearconvert ../tslinux/usr/sbin/
  lrwxrwxrwx 1 arm arm    13 2007-05-23 11:30 dropbear -> dropbearmulti
+
  $ mv dbclient ../tslinux/usr/bin
lrwxrwxrwx 1 arm arm    13 2007-05-23 11:28 dropbearconvert -> dropbearmulti
 
  lrwxrwxrwx 1 arm arm    13 2007-05-23 11:28 dropbearkey -> dropbearmulti
 
-rwxr-xr-x 1 arm arm 821396 2007-05-23 11:24 dropbearmulti
 
lrwxrwxrwx 1 arm arm    13 2007-05-23 11:27 scp -> dropbearmulti
 
  
= dropbear =
+
= booting =
 +
 
 +
== disable ssh for inetd ==
 +
 
 +
$ cat etc/inetd.conf | grep ssh
 +
#ssh    stream  tcp    nowait  root    /usr/sbin/dropbear      dropbear -i
 +
$ kill -HUP <pid of inetd>
 +
 
 +
== create init.d script ==
 +
 
 +
$ cat etc/init.d/dropbear 
 +
OPTIONS="> /dev/null 2>&1"
 +
 +
case "$1" in
 +
    start)
 +
        echo "Starting dropbear..."
 +
        /usr/sbin/dropbear $OPTIONS
 +
    ;;
 +
    stop)
 +
        echo "Stopping dropbear..."
 +
        pid=`pidof dropbear`
 +
        if [ "$pid" != "" ]; then
 +
            kill $pid
 +
        fi
 +
    ;;                   
 +
    restart)
 +
        $0 stop
 +
        $0 start
 +
    ;;
 +
    *)
 +
        echo "usage: start|stop|restart"
 +
    ;;
 +
esac
 +
 
 +
== create rc link ==
 +
$ cd etc/rc.d/rc3.d/
 +
$ ln -s ../../init.d/dropbear S99dropbear
 +
 
 +
== fix dropbear errors by recreating links ==
 +
 
 +
ssh to ts-board and make create a bash script like this one:
 +
* Note: TS-7260 uses sh, so use: #!/bin/sh instead of #!/bin/bash
 +
 
 +
#!/bin/sh
 +
# Remove All /usr/sbin
 +
rm -rf /usr/sbin/scp
 +
rm -rf /usr/sbin/ssh
 +
rm -rf /usr/sbin/dbclient
 +
rm -rf /usr/sbin/dropbear
 +
rm -rf /usr/sbin/dropbearkey
 +
rm -rf /usr/sbin/dropbearconvert
 +
 
 +
# Remove All /usr/bin
 +
rm -rf /usr/bin/scp
 +
rm -rf /usr/bin/ssh
 +
rm -rf /usr/bin/dbclient
 +
rm -rf /usr/bin/dropbear
 +
rm -rf /usr/bin/dropbearkey
 +
rm -rf /usr/bin/dropbearconvert
 +
 
 +
# Link All /usr/sbin
 +
ln -s /usr/sbin/dropbearmulti /usr/sbin/scp
 +
ln -s /usr/sbin/dropbearmulti /usr/sbin/ssh
 +
ln -s /usr/sbin/dropbearmulti /usr/sbin/dbclient
 +
ln -s /usr/sbin/dropbearmulti /usr/sbin/dropbear
 +
ln -s /usr/sbin/dropbearmulti /usr/sbin/dropbearkey
 +
ln -s /usr/sbin/dropbearmulti /usr/sbin/dropbearconvert
 +
 
 +
# Link All /usr/bin
 +
ln -s /usr/sbin/dropbearmulti /usr/bin/scp
 +
ln -s /usr/sbin/dropbearmulti /usr/bin/ssh
 +
ln -s /usr/sbin/dropbearmulti /usr/bin/dbclient
 +
ln -s /usr/sbin/dropbearmulti /usr/bin/dropbear
 +
ln -s /usr/sbin/dropbearmulti /usr/bin/dropbearkey
 +
ln -s /usr/sbin/dropbearmulti /usr/bin/dropbearconvert
  
 
= links =
 
= links =
 
* [http://omnifi.cwtsecure.com/index.php?title=DMP1_SSHD DMP1 SSHD]
 
* [http://omnifi.cwtsecure.com/index.php?title=DMP1_SSHD DMP1 SSHD]
 
* [http://omnifi.cwtsecure.com/index.php?title=Compile_Programs Compile Programs]
 
* [http://omnifi.cwtsecure.com/index.php?title=Compile_Programs Compile Programs]
 +
* [http://www.nomis52.net/?section=projects&sect2=netgear&page=dropbear dropbear netgear]

Latest revision as of 13:17, 20 May 2008

about

This page describes how to compile dropbear to run in Technologic System's TS-Linux for ARM distribution. Debian was used for development and cross compiling. The TS-7260's root file system uses the RedBoot NFS option.

compiling

crosstool setup

download and setup ts crosstool package

  • At the time of this writing, the Linux Crosstool gcc-4.0.1-glibc-2.3.5 -- unknown (05-20-2006) was available
ftp://ftp.embeddedarm.com/ts-arm-linux-cd/cross-toolchains/crosstool-linux-gcc-4.0.1-glibc-2.3.5.tar.bz2

move it to / and unpack it

$ cd /
$ sudo tar -xf crosstool-linux-gcc-4.0.1-glibc-2.3.5.tar

add it to your path

$ cat ~/.bash_profile | grep cross
PATH=/opt/crosstool/gcc-4.0.1- glibc-2.3.5/arm-unknown-linux-gnu/bin:${PATH}

dropbear

download dropbear

$ wget http://matt.ucc.asn.au/dropbear/releases/dropbear-0.49.tar.bz2
$ cd dropbear-0.49/

configure/make

  • dropbear needs access to a good random pool in /dev/random and for some reason it would always hang on /dev/random and would print this message while running:
Warning: Reading the random source seems to have blocked.
If you experience problems, you probably need to find a better entropy source. 
  • so i edited options.h and changed the random device to be urandom for this error.
#define DROPBEAR_RANDOM_DEV "/dev/urandom"
  • the shell script i used to automate the build process
$ cat run.sh 
export CFLAGS="-Os -static -Wall"
export LDFLAGS="-static"
./configure --host=arm-unknown-linux-gnu --build=arm --disable-zlib --disable-syslog --disable-lastlog (optionally add --enable-static)
make clean
make PROGRAMS="dropbear dbclient dropbearkey dropbearconvert scp" MULTI=1 STATIC=1

move files

  • relocate files to nfs directory
$ ln -s dropbearmulti ssh
$ mv dropbear ssh scp dropbearmulti dropbearkey dropbearconvert ../tslinux/usr/sbin/
$ mv dbclient ../tslinux/usr/bin

booting

disable ssh for inetd

$ cat etc/inetd.conf | grep ssh
#ssh    stream  tcp     nowait  root    /usr/sbin/dropbear      dropbear -i
$ kill -HUP <pid of inetd>

create init.d script

$ cat etc/init.d/dropbear  
OPTIONS="> /dev/null 2>&1"

case "$1" in
    start)
       echo "Starting dropbear..."
       /usr/sbin/dropbear $OPTIONS
    ;;
    stop)
        echo "Stopping dropbear..."
        pid=`pidof dropbear`
        if [ "$pid" != "" ]; then
           kill $pid
        fi 
    ;;                     
    restart)
        $0 stop 
        $0 start
    ;;
    *)
       echo "usage: start|stop|restart"
    ;;
esac

create rc link

$ cd etc/rc.d/rc3.d/
$ ln -s ../../init.d/dropbear S99dropbear

fix dropbear errors by recreating links

ssh to ts-board and make create a bash script like this one:

  • Note: TS-7260 uses sh, so use: #!/bin/sh instead of #!/bin/bash
#!/bin/sh
# Remove All /usr/sbin
rm -rf /usr/sbin/scp
rm -rf /usr/sbin/ssh
rm -rf /usr/sbin/dbclient
rm -rf /usr/sbin/dropbear
rm -rf /usr/sbin/dropbearkey
rm -rf /usr/sbin/dropbearconvert
# Remove All /usr/bin
rm -rf /usr/bin/scp
rm -rf /usr/bin/ssh
rm -rf /usr/bin/dbclient
rm -rf /usr/bin/dropbear
rm -rf /usr/bin/dropbearkey
rm -rf /usr/bin/dropbearconvert
# Link All /usr/sbin
ln -s /usr/sbin/dropbearmulti /usr/sbin/scp
ln -s /usr/sbin/dropbearmulti /usr/sbin/ssh
ln -s /usr/sbin/dropbearmulti /usr/sbin/dbclient
ln -s /usr/sbin/dropbearmulti /usr/sbin/dropbear
ln -s /usr/sbin/dropbearmulti /usr/sbin/dropbearkey
ln -s /usr/sbin/dropbearmulti /usr/sbin/dropbearconvert
# Link All /usr/bin
ln -s /usr/sbin/dropbearmulti /usr/bin/scp
ln -s /usr/sbin/dropbearmulti /usr/bin/ssh
ln -s /usr/sbin/dropbearmulti /usr/bin/dbclient
ln -s /usr/sbin/dropbearmulti /usr/bin/dropbear
ln -s /usr/sbin/dropbearmulti /usr/bin/dropbearkey
ln -s /usr/sbin/dropbearmulti /usr/bin/dropbearconvert

links