2010年4月14日 星期三

cross compile ssh daemon(dropbear) for arm

1. Get zlib(included by dropbear)
#wget http://www.zlib.net/zlib-1.2.3.tar.gz
#tar zxvf zlib-1.2.3.tar.gz
#mkdir zlib
#cd zlib-1.2.3/
#CC=arm-none-linux-gnueabi-gcc ./configure --prefix=/zlib
#make
#make install

2. Get dropbear source
#wget http://matt.ucc.asn.au/dropbear/releases/dropbear-0.51.tar.gz
#tar zxvf dropbear-0.51.tar.gz
#mkdir dropbear-build
#cd dropbear-build/
#mkdir build
#../dropbear-0.51/configure --prefix=/build/ \
--with-zlib=/zlib/ CC=arm-none-linux-gnueabi-gcc --host=arm-none-linux-gnueabi LDFLAGS=-static
#make
#sudo make install

3. Copy dbclient, dropbearconvert, dropbearkey, and dropbear binarys to your file system and generate the cpio.gz file(Under build/bin and build/sbin, if you are not using a emulator, do not generate cpio.gz file :))

4. In target,
#cd /etc
#mkdir dropbear
#cd dropbear
#dropbearkey -t rsa -f dropbear_rsa_host_key

if indicate "Exited: couldn't open random device", do the following
#mknod -m=666 /dev/random c 1 8
#mknod -m=666 /dev/urandom c 1 9

#dropbear(assume the binary is under /sbin)

5. Done, you should be able to run ssh client to access this machine.
(May add password if it's originally none, otherwise ssh will complain permission denied)

PS. If you encountered the following error when ssh to the target.
"PTY allocation request failed on channel 0"
"shell request failed on channel 0"
do the following:

# mkdir /dev/pts
# mknod /dev/ptmx c 5 2
# mount -t devpts devpts /dev/pts

沒有留言: