平台:rk3399
有个需求需要设备支持ssh功能,这东西网上也有类似的资料.
具体的需求是客户提供ssh的公钥,公钥加入到固件里面,烧录后开机起来,设备用ssh 就可以直接连上3399.
本来是做openbear的支持,因为有设备在5.1上支持过,编译没问题,但连接的时候总是被拒绝,找了很久原因没解决,很绝望,只好回头来搞openssh的.
好了,进入主题,其实源码里面external/openssh有了,external/zlib已经支持了,openssl的库也支持了,所以只需要调试openssh.
步骤1:device/rockchip/rk3399/rk3399.mk 添加:
diff --git a/device/rockchip/rk3399/rk3399.mk b/device/rockchip/rk3399/rk3399.mk
index 9125ef8..ab35580 100755
--- a/device/rockchip/rk3399/rk3399.mk
+++ b/device/rockchip/rk3399/rk3399.mk
@@ -52,6 +52,18 @@ PRODUCT_PACKAGES += \
MmsService
+
+# Openssh
+PRODUCT_PACKAGES += \
+ scp \
+ sftp \
+ ssh \
+ sshd \
+ sshd_config \
+ ssh-keygen \
+ start-ssh
编译烧录system.img后,板子上已经有ssh相关命令了
步骤2:先创建出几个key:
mkdir -p /data/ssh
mkdir -p /data/ssh/empty
chmod 700 /data/ssh
chmod 700 /data/ssh/empty
cd /data/ssh/
ssh-keygen -t rsa -f ssh_host_rsa_key -N “”
ssh-keygen -t dsa -f ssh_host_dsa_key -N “”
ssh-keygen -t ecdsa -f ssh_host_ecdsa_key -N ""
步骤3:将我们电脑上的公钥push进去
adb push id_rsa.pub /data/ssh/authorized_keys
步骤4:更改sshd服务配置文件/system/etc/ssh/sshd_config
将#Port 22改为Port 22
讲#PermitRootLogin yes改为PermitRootLogin without-password
将#RSAAuthentication yes改为RSAAuthentication yes
将#PubkeyAuthentication yes改为PubkeyAuthentication yes
将PasswordAuthentication no改为#PasswordAuthentication no
将#PermitEmptyPasswords no改为PermitEmptyPasswords yes
将#ChallengeResponseAuthenticationyes改为ChallengeResponseAuthentication yes
将#UsePrivilege