# android-dropbear-install-script **Repository Path**: NingOpenSource/android-dropbear-install-script ## Basic Information - **Project Name**: android-dropbear-install-script - **Description**: dropbear的安卓安装脚本 - **Primary Language**: Shell - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2021-03-30 - **Last Updated**: 2021-03-30 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # android-dropbear-install-script #### 介绍 dropbear的安卓安装脚本,参考:[Android安装ssh服务](https://www.cnblogs.com/whltingyu/p/4083448.html) ### 依赖项目 1. `busybox`:[官网](https://busybox.net/) 1. `dropbear`:[github.com/mkj/dropbear](https://github.com/mkj/dropbear), [gitee.com/mirrors/dropbear](https://gitee.com/mirrors/dropbear) 1. `android-dropbear`:[github.com/ribbons/android-dropbear](https://github.com/ribbons/android-dropbear), [github.com/ribbons/android-dropbear](https://github.com/ribbons/android-dropbear) 二进制包下载地址:[`hub.fastgit.org`镜像](https://hub.fastgit.org/ribbons/android-dropbear/releases) ### 执行脚本 安装busybox ```shell adb remount adb push busybox /system/xbin/ adb shell adb shell chmod 0755 /system/xbin/busybox adb shell busybox --install -s /system/xbin/ ``` 安装dropbear ```shell adb remount # 将dropbear相关的文件push进手机 adb push dropbear /system/xbin/ adb push dropbearkey /system/xbin/ adb push dropbearconvert /system/xbin/ adb shell chmod 0744 /system/xbin/dropbear* # 创建dropbear的目录 adb shell mkdir /data/dropbear adb shell mkdir /data/dropbear/.ssh # 生成服务器密钥 adb shell dropbearkey -t dss -f /data/dropbear/dss_host_key # 将登陆密钥放置到服务器 adb push Identity.pub /data/dropbear/.ssh/ adb shell mv /data/dropbear/.ssh/Identity.pub /data/dropbear/.ssh/authorized_keys adb shell chmod 744 /data/dropbear/.ssh/authorized_keys # 脚本会创建用户相关的配置文件,否则无法登陆 adb push createfiles.sh /data/dropbear adb shell chmod -R 0744 /data/dropbear adb shell /data/dropbear/createfiles.sh # 启动服务器测试 (实际应用可以去掉-F选项,运行于后台) adb shell dropbear -d /data/dropbear/dss_host_key -F -E -s -v ``` createfiles.sh内容: ```shell echo "root:x:0:0::/root:/system/bin/sh" > /etc/passwd echo "root::14531:0:99999:7:::" > /etc/shadow echo "root:x:0:" > /etc/group echo "root:!::" > /etc/gshadow echo "/system/bin/sh" > /etc/shells echo "PATH=\"/usr/bin:/usr/sbin:/bin:/sbin:/system/sbin:/system/bin:/system/xbin:/data/local/bin\"" > /etc/profile echo "export PATH" >> /etc/profile ``` 卸载dropbear ```shell adb remount adb shell rm /system/xbin/dropbear adb shell rm /system/xbin/dropbearkey adb shell rm /system/xbin/dropbearconvert adb shell rm -rf /data/dropbear adb shell rm /etc/passwd adb shell rm /etc/shadow adb shell rm /etc/group adb shell rm /etc/gshadow adb shell rm /etc/shells adb shell rm /etc/profile ```