1.需求 Android虽然提供了ADB,但还是没有ssh,scp等用起来顺手,所以想移植一个ssh的Server到开发板上去,因为android默认的代码有external/dropbear,所以决定移植dropbear而不是openssh; 2. 思路 要实现ssh,scp必须要满足以下的条件: A) 必须要有网路,这个可以由wifi来保证; B) 必须要有一个Server来打开22号端口,这个是由dropbear来完成的; C) 必须要有一个scp在开发板上,这样才能实现scp的功能; 3. 适用范围 以下的步骤只适用于平台开发者,在最终产品里面必须要拿掉这个功能; 测试环境: 硬件:pxa310; Android:2.1 理论上在其它硬件和android版本也应该可以工作,也许需要做微调; 4. 移植步骤 4.1 dropbear,dropbearkey的生成 a) 把android_root/external/dropbear这个目录copy一份,假设为dropbear.bak; b) 进入到dropbear.bak,做一定的修改,修改的diff如下: diff --git a/Android.mk b/Android.mk deleted file mode 100644 index b95d5dd..0000000 --- a/Android.mk +++ /dev/null @@ -1,56 +0,0 @@ -ifneq ($(TARGET_SIMULATOR),true) - -LOCAL_PATH:= $(call my-dir) -include $(CLEAR_VARS) - -LOCAL_SRC_FILES:=/ - dbutil.c buffer.c / - dss.c bignum.c / - signkey.c rsa.c random.c / - queue.c / - atomicio.c compat.c fake-rfc2553.c -LOCAL_SRC_FILES+=/ - common-session.c packet.c common-algo.c common-kex.c / - common-channel.c common-chansession.c termcodes.c / - tcp-accept.c listener.c process-packet.c / - common-runopts.c circbuffer.c -# loginrec.c -LOCAL_SRC_FILES+=/ - cli-algo.c cli-main.c cli-auth.c cli-authpasswd.c cli-kex.c / - cli-session.c cli-service.c cli-runopts.c cli-chansession.c / - cli-authpubkey.c cli-tcpfwd.c cli-channel.c cli-authinteract.c -LOCAL_SRC_FILES+=netbsd_getpass.c - -LOCAL_STATIC_LIBRARIES := libtommath libtomcrypt - -LOCAL_MODULE_PATH := $(TARGET_OUT_OPTIONAL_EXECUTABLES) -LOCAL_MODULE_TAGS := eng -LOCAL_MODULE := ssh -LOCAL_C_INCLUDES += $(LOCAL_PATH)/libtommath -LOCAL_C_INCLUDES += $(LOCAL_PATH)/libtomcrypt/src/headers -LOCAL_CFLAGS += -DDROPBEAR_CLIENT - -include $(BUILD_EXECUTABLE) - -include $(CLEAR_VARS) - -LOCAL_SRC_FILES:=/ - scp.c progressmeter.c atomicio.c scpmisc.c - -LOCAL_STATIC_LIBRARIES := libtommath libtomcrypt - -LOCAL_MODULE_PATH := $(TARGET_OUT_OPTIONAL_EXECUTABLES) - -LOCAL_MODULE_TAGS := debug - -LOCAL_MODULE := scp -LOCAL_C_INCLUDES += $(LOCAL_PATH)/libtommath -LOCAL_C_INCLUDES += $(LOCAL_PATH)/libtomcrypt/src/headers -LOCAL_CFLAGS += -DDROPBEAR_CLIENT -DPROGRESS_METER - -include $(BUILD_EXECUTABLE) - -endif # TARGET_SIMULATOR != true - - -include $(call all-makefiles-under,$(LOCAL_PATH)) diff --git a/config.h b/config.h index 5c67988..ff482ce 100644 --- a/config.h +++ b/config.h @@ -50,7 +50,7 @@ #define DISABLE_WTMPX 1 /* Use zlib */ -#define DISABLE_ZLIB 1 +/* #undef DISABLE_ZLIB */ /* Define to 1 if you have the `basename' function. */ #define HAVE_BASENAME 1 @@ -62,7 +62,7 @@ #define HAVE_CONST_GAI_STRERROR_PROTO 1 /* Define to 1 if you have the header file. */ -/* #define HAVE_CRYPT_H */ +#define HAVE_CRYPT_H 1 /* Define to 1 if you have
Android移植之dropbear
最新推荐文章于 2021-05-30 20:51:45 发布
本文详细介绍了如何在Android系统上移植Dropbear SSH Server,包括移植步骤、配置和编译过程,以及如何使用scp和ssh命令。移植完成后,可以在开发板上通过ssh登录并实现数据传输。
摘要由CSDN通过智能技术生成