- 编译
https://quantum6.blog.csdn.net/article/details/136299665
编译时指定prefix,产生的文件会自带这个目录。所以直接忽略。
./configure# 不指定编译路径,手动复制。
- 复制
编译后的整个目录打包,复制到开发板。写个脚本,内容如下,执行:
INSTALL=/usr/bin/install
MKDIR=/usr/bin/mkdir${MKDIR} -p -m 0755 /var/emptyU_L_SBIN=/usr/local/sbin
echo
echo ${U_L_SBIN}
${MKDIR} -p ${U_L_SBIN}
${INSTALL} -c -m 0755 sshd ${U_L_SBIN}/sshdU_L_BIN=/usr/local/bin
echo
echo ${U_L_BIN}
${MKDIR} -p ${U_L_BIN}
${INSTALL} -c -m 0755 ssh ${U_L_BIN}/ssh
${INSTALL} -c -m 0755 scp ${U_L_BIN}/scp
${INSTALL} -c -m 0755 ssh-add ${U_L_BIN}/ssh-add
${INSTALL} -c -m 0755 ssh-agent ${U_L_BIN}/ssh-agent
${INSTALL} -c -m 0755 ssh-keygen ${U_L_BIN}/ssh-keygen
${INSTALL} -c -m 0755 ssh-keyscan ${U_L_BIN}/ssh-keyscan
${INSTALL} -c -m 0755 sftp ${U_L_BIN}/sftpU_L_LIBEXEC=/usr/local/libexec
echo
echo ${U_L_LIBEXEC}
${MKDIR} -p ${U_L_LIBEXEC}
${INSTALL} -c -m 4711 ssh-keysign ${U_L_LIBEXEC}/ssh-keysign
${INSTALL} -c -m 0755 ssh-pkcs11-helper ${U_L_LIBEXEC}/ssh-pkcs11-helper
${INSTALL} -c -m 0755 ssh-sk-helper ${U_L_LIBEXEC}/ssh-sk-helper
${INSTALL} -c -m 0755 sftp-server ${U_L_LIBEXEC}/sftp-serverU_L_S_M_MAN1=/usr/local/share/man/man1
echo
echo ${U_L_S_M_MAN1}
${MKDIR} -p ${U_L_S_M_MAN1}
${INSTALL} -c -m 644 ssh.1.out ${U_L_S_M_MAN1}/ssh.1
${INSTALL} -c -m 644 scp.1.out ${U_L_S_M_MAN1}/scp.1
${INSTALL} -c -m 644 ssh-add.1.out ${U_L_S_M_MAN1}/ssh-add.1
${INSTALL} -c -m 644 ssh-agent.1.out ${U_L_S_M_MAN1}/ssh-agent.1
${INSTALL} -c -m 644 ssh-keygen.1.out ${U_L_S_M_MAN1}/ssh-keygen.1
${INSTALL} -c -m 644 ssh-keyscan.1.out ${U_L_S_M_MAN1}/ssh-keyscan.1
${INSTALL} -c -m 644 sftp.1.out ${U_L_S_M_MAN1}/sftp.1U_L_S_M_MAN5=/usr/local/share/man/man5
echo
echo ${U_L_S_M_MAN5}
${MKDIR} -p ${U_L_S_M_MAN5}
${INSTALL} -c -m 644 moduli.5.out ${U_L_S_M_MAN5}/moduli.5
${INSTALL} -c -m 644 sshd_config.5.out ${U_L_S_M_MAN5}/sshd_config.5
${INSTALL} -c -m 644 ssh_config.5.out ${U_L_S_M_MAN5}/ssh_config.5U_L_S_M_MAN8=/usr/local/share/man/man8
echo
echo ${U_L_S_M_MAN8}
${MKDIR} -p ${U_L_S_M_MAN8}
${INSTALL} -c -m 644 sshd.8.out ${U_L_S_M_MAN8}/sshd.8
${INSTALL} -c -m 644 sftp-server.8.out ${U_L_S_M_MAN8}/sftp-server.8
${INSTALL} -c -m 644 ssh-keysign.8.out ${U_L_S_M_MAN8}/ssh-keysign.8
${INSTALL} -c -m 644 ssh-pkcs11-helper.8.out ${U_L_S_M_MAN8}/ssh-pkcs11-helper.8
${INSTALL} -c -m 644 ssh-sk-helper.8.out ${U_L_S_M_MAN8}/ssh-sk-helper.8U_L_ETC=/usr/local/etc
echo
echo ${U_L_ETC}
${MKDIR} -p ${U_L_ETC}
${INSTALL} -c -m 644 ssh_config.out ${U_L_ETC}/ssh_config
${INSTALL} -c -m 644 sshd_config.out ${U_L_ETC}/sshd_config
${INSTALL} -c -m 644 moduli.out ${U_L_ETC}/moduli
- 准备工作
ssh-keygen -A
- 产生KEY(实际上已经复制,不需要)
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 ""
ssh-keygen -t dsa -f ssh_host_ed25519_key -N ""
- 增加sshd用户
sshd: Privilege separation user sshd does not exist-CSDN博客
- 缺少依赖库
我的板子缺少libz.so/libcrypto.so,复制到/lib64下,解决。
/usr/local/sbin/sshd
sshd: error while loading shared libraries: libz.so.1: cannot open shared object file: No such file or directorylrwxrwxrwx 1 root root 9 Jan 1 00:15 /lib64/libz.so -> libz.so.1
lrwxrwxrwx 1 root root 14 Jan 1 00:15 /lib64/libz.so.1 -> libz.so.1.2.11
-rw-r----- 1 root root 117032 Jan 1 00:15 /lib64/libz.so.1.2.11lrwxrwxrwx 1 root root 16 Jan 1 00:15 /lib64/libcrypto.so -> libcrypto.so.1.1
-rw-r----- 1 root root 2711280 Jan 1 00:15 /lib64/libcrypto.so.1.1
- 检查配置文件是否正确
/usr/local/sbin/sshd -t -f /usr/local/etc/sshd_config
- 修改配置文件,允许ROOT登录
通过SSH使用ROOT账号无法登录,提示禁止访问Access denied_ssh root拒绝访问-CSDN博客
- 运行
/usr/local/sbin/sshd -f /usr/local/etc/sshd_configps | grep sshd
1501 root 0:00 sshd: /usr/local/sbin/sshd -f /usr/local/etc/sshd_config [listener
可以看到已经启动到后台了。可以使用ssh登录了。