安卓系统添加dropbear实例

 

 

 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)

源码下载连接:http://download.csdn.net/download/kai_zone/10042115

 

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

kevin@1024

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值