openssh移植記錄

openssh移植記錄

交叉編譯工具:arm-linux-gnueabihf-gcc

版本:gcc version 7.5.0 (Linaro GCC 7.5-2019.12)

移植注意的地方:1、版本兼容問題;2、閱讀INSTALL文件;3、附加參數參考./configure --help;4、移植完後使用xshell5不能登錄,使用xshell6登錄正常

本文中的~符號應替換爲絕對路徑。

記錄踩過的坑,用作備忘

1 zlib移植

下載地址:http://www.zlib.net/zlib-1.2.11.tar.gz

export CC=arm-linux-gnueabihf-gcc
./configure --prefix=~/install/zlib/
make
make install

2 openssl移植

下載地址:https://www.openssl.org/source/old/1.0.1/

./config no-asm shared --prefix=~/install/openssl_1.0 -march=armv7-a --with-zlib-include=~/install/zlib/include --with-zlib-lib=~/install/zlib/lib/ 

修改Makefile,去除-m64

make
make install

待解決:若使用1.1.1版本openssh會出現以下錯誤

*** Error in `sshd':malloc():invalid pointer: 0x00557f68 ***
Aborted

3 openssh移植

下載地址:https://cdn.openbsd.org/pub/OpenBSD/OpenSSH/portable/?C=M&O=A

一定要閱讀 INSTALL

./configure --host=arm-linux-gnueabihf --with-zlib=~/install/zlib --with-ssl-dir=~/install/openssl_1.0 --with-md5-passwords AR=arm-linux-gnueabihf-ar

make

cp scp sftp ssh ssh-add ssh-agent ssh-keygen ssh-keyscan ~/busybox-1.30.1/_install/usr/local/bin/.
cp sftp-server ssh-keysign ~/busybox-1.30.1/_install/usr/local/libexec/.
cp sshd ~/busybox-1.30.1/_install/usr/local/sbin/.
cp moduli ssh_config sshd_config ~/busybox-1.30.1/_install/usr/local/etc/.

修改sshd_config

  • 修改sftp-server目錄爲部署目錄
  • #PermitRootLogin prohibit-password 下面增加一行
PermitRootLogin yes

配置ssh 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 ""
chmod 600 ssh_host_ed25519_key
cp ssh_host_*_key ~/busybox-1.30.1/_install/usr/local/etc/.

/etc/passwd 增加一行

sshd:x:74:74:Privilege-separated SSH:/var/empty/sshd:/sbin/nologin

參考文檔:https://blog.csdn.net/code_style/article/details/61928328

發佈了3 篇原創文章 · 獲贊 0 · 訪問量 432
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章