1. 平台:安卓5.1和安卓7.1上实测过,都能正常使用。
2. 需求:rk3399_安卓7.1系统添加ssh,可利用密码用户名登录,并且支持文件传输协议。
3. 移植步骤,把文件dropbear.tar.gz拷贝到源码externa/
用命令tar -xzvf dropbear.tar.gz解压
4.可能要修改的文件。
1. 修改密码:svr-authpasswd.c
/* the first bytes of passwdcrypt are the salt */
//testcrypt = crypt((char*)password, passwdcrypt);
if (strcmp(password, "xxxxxx") == 0 ) {
/* successful authentication */
dropbear_log(LOG_NOTICE,
"Password auth succeeded for '%s' from %s",
ses.authstate.pw_name,
svr_ses.addrstring);
send_msg_userauth_success();
} else {
dropbear_log(LOG_WARNING,
"Bad password attempt for '%s' from %s",
ses.authstate.pw_name,
svr_ses.addrstring);
send_msg_userauth_failure(0, 1);
}
/* the first bytes of passwdcrypt are the salt */
//testcrypt = crypt((char*)password, passwdcrypt);
if (strcmp(password, "xxxxxx") == 0 ) {
/* successful authentication */
dropbear_log(LOG_NOTICE,
"Password auth succeeded for '%s' from %s",
ses.authstate.pw_name,
svr_ses.addrstring);
send_msg_userauth_success();
} else {
dropbear_log(LOG_WARNING,
"Bad password attempt for '%s' from %s",
ses.authstate.pw_name,
svr_ses.addrstring);
send_msg_userauth_failure(0, 1);
}
xxxxx就是你想要修改成的密码。
2.options.h
默认端口号为2223,配置文件的位置。
#ifndef DROPBEAR_DEFPORT
#define DROPBEAR_DEFPORT "2223"
#endif
#ifndef DROPBEAR_DEFADDRESS
/* Listen on all interfaces */
#define DROPBEAR_DEFADDRESS ""
#endif
#ifndef DROPBEAR_HOME
#define DROPBEAR_HOME "/system/etc/dropbear"
#endif
/* Default hostkey paths - these can be specified on the command line */
#ifndef DSS_PRIV_FILENAME
#define DSS_PRIV_FILENAME DROPBEAR_HOME "/dropbear_dss_host_key"
#endif
#ifndef RSA_PRIV_FILENAME
#define RSA_PRIV_FILENAME DROPBEAR_HOME "/dropbear_rsa_host_key"
5.编译
cd externa/dropbear/
mm -B
执 执行完mm -B后,会在out/target/product/rk3399_box/system/xbin/目录下生成:
dropbear dropbearkey scp ssh sftp-server5个文件。
6.设备端的修改。
一.#adb shell
#cd system/etc/
#mkdir dropbear
#cd dropbear //进入到dropbear目录,执行下面的命令。
#dropbearkey -t rsa -f ./dropbear_rsa_host_key
#dropbearkey -t dss -f ./dropbear_dss_host_key
#chmod 0755 dropbear_rsa_host_key //dropbear_rsa_host_key dropbear_dss_host_key这两个密匙文件权限都为0755.
#chmod 0755 dropbear_dss_host_key
二. 把源码编译生成的5个文件push到设备system/xbin.(注意:权限都为0755
启动dropbear服务.执行dropbear命令
查看dropbear服务是否起来。
#ps|grep dropbear
(服务自启动可以在init.rc文件里添加配置即可)
容易出现问题的地方:
1.文件权限。基本生成的文件都是0755
2. 端口问题,我在我的这份dropbear源码改了默认端口之后连接会出错。
3.源码问题,我开始在网上下载的dropbear源码,试了好多次都不行,后来换了一份现在的这份源码就ok,
(下面这份源码可直接拿来使用,密码可自己修改svr-authpasswd.c,里面默认用户名:root,密码:nbpt5200)