【全志V821_FoxPi】4-1嵌入式系统使能openssh @root
【全志V821_FoxPi】4-1嵌入式系统使能openssh @root
- 一、背景
- 二、系统使能openssh
- 三、系统配置自定义
-
- 3-1 /etc/init.d/S60sshd
- 3-2 /etc/ssh/sshd_config
- 3-3 /etc/group
- 3-4 /etc/passwd (sshd)
- 3-5 /etc/inittab (可选)
- 3-6 /etc/passwd (root)
- 3-7 /etc/wifi/wifimg.config
- 四、编译打包烧录测试
一、背景
在全志V821的板子,通过串口连接来调试或者adb调试的方法是挺好的,但是如果想通过远程进行debug,以及方便文件传输,感觉还是通过网络来调试会快乐一些,而且全志V821是自带wifi的,可以充分利用这一优势。
下面将分享如何适配全志V821的openssh功能。
注:当前使用的是全志V821 Tina SDK V1.2
二、系统使能openssh
在source 和lunch之后,我们通过 make menuconfig
进行使能openssh
直接搜索 openssh
找到PACKAGE_openssh相关的软件包
使能以下三个:
注:openssh-server 使用带 pam 版本
- openssh-keygen
- openssh-server-pam
- openssh-sftp-server
三、系统配置自定义
以下配置均在SDK的方案目标板子的target的busybox-init-base-files中修改,我的路径在:
(仅供参考)
/opt/Tina_V821_V1.2/openwrt/target/v821/v821-foxpi_ipc/busybox-init-base-files#
3-1 /etc/init.d/S60sshd
目的:对默认的启动脚本稍作修改,以实现openssj自启动
操作:在 /etc/init.d 新建 S60sshd 文件,写入以下内容:
#!/bin/sh /etc/rc.common
# Copyright (C) 2006-2011 OpenWrt.orgSTART=50
STOP=50USE_PROCD=1
PROG=/usr/sbin/sshdstart_service() {for type in rsa ed25519do# check for keyskey=/etc/ssh/ssh_host_${type}_key[ ! -f $key ] && {# generate missing keys[ -x /usr/bin/ssh-keygen ] && {/usr/bin/ssh-keygen -N '' -t $type -f $key 2>&- >&-}}donemkdir -m 0700 -p /var/emptylocal lport=$(awk '/^Port / { print $2; exit }' /etc/ssh/sshd_config)[ -z "$lport" ] && lport=22procd_open_instance#procd_add_mdns "ssh" "tcp" "$lport"procd_set_param command $PROG -Dprocd_close_instance
}shutdown() {local pidstop# kill active clientsfor pid in $(pidof sshd)do[ "$pid" = "$$" ] && continue[ -e "/proc/$pid/stat" ] && kill $piddone
}
3-2 /etc/ssh/sshd_config
目的:对默认的启动参数稍作修改,以实现openssj自启动(允许root登录等)
操作:在 /etc/ssh新建 sshd_config 文件,写入以下内容:
# $OpenBSD: sshd_config,v 1.103 2018/04/09 20:41:22 tj Exp $# This is the sshd server system-wide configuration file. See
# sshd_config(5) for more information.# This sshd was compiled with PATH=/usr/bin:/bin:/usr/sbin:/sbin# The strategy used for options in the default sshd_config shipped with
# OpenSSH is to specify options with their default value where
# possible, but leave them commented. Uncommented options override the
# default value.Port 22
AddressFamily any
ListenAddress 0.0.0.0
#ListenAddress ::HostKey /etc/ssh/ssh_host_rsa_key
#HostKey /etc/ssh/ssh_host_ecdsa_key
HostKey /etc/ssh/ssh_host_ed25519_key# Ciphers and keying
#RekeyLimit default none# Logging
#SyslogFacility AUTH
#LogLevel INFO# Authentication:#LoginGraceTime 2m
PermitRootLogin ye