下載源碼包:
openssh http://www.openssh.com/portable.html
openssl http://www.openssl.org/source
zlib http://www.zlib.net/
推薦版本:zlib-1.2.11.tar.gz,openssl-1.0.2q.tar.gz,openssh-8.2p1.tar.gz
mkdir compressed install source
compressed 用於存放源碼包
install 軟件安裝目錄
source 源碼包解壓目錄
cd zlib
prefix=~/work/ssh/install/zlib CC=arm-himix410-linux-gcc AR=arm-himix410-linux-ar ./configure
如果需要生成so庫的話需要加上 --shared
vim Makefile
CC=arm-himix410-linux-gcc
CPP=arm-himix410-linux-g++
AR=arm-himix410-linux-ar
make
make install
cd openssl
./Configure --prefix=~/work/ssh/install/openssl os/compiler:arm-himix410-linux-gcc -fPIC no-asm shared
make CC=arm-himix410-linux-gcc AR=arm-himix410-linux-ar
make install
cd openssh
./configure --host=arm-himix410-linux --with-libs --with-zlib=~/work/ssh/install/zlib --with-ssl-dir=~/work/ssh/install/openssl --disable-etc-default-login CC=arm-himix410-linux-gcc AR=arm-himix410-linux-ar
make
操作目標板:
確保目標板有以下目錄,如果沒有則新建:
/usr/local/bin
/usr/local/etc
/usr/local/libexec
/var/run
/var/empty/sshd
chown -R root.root /var/empty/sshd
chmod 744 /var/empty/sshd
將 openssh 目錄下文件拷貝到開發板系統中,具體為:
scp、sftp、ssh 、ssh-add、ssh-agent、ssh-keygen、ssh-keyscan 共7個文件拷貝到開發板 /usr/local/bin
moduli、ssh_config、sshd_config 共3個文件拷貝到開發板 /usr/local/etc
sftp-server、ssh-keysign 共2個文件拷貝到開發板 /usr/local/libexec
sshd 拷貝到 /usr/sbin
chmod 777 /usr/sbin/sshd
libz.so.1.2.11 拷貝到開發板 /lib (必須放在/lib下,不然scp會找不到這個庫)
然后建立軟鏈接:
ln -s libz.so.1.2.11 libz.so.1
生成key文件:
ssh-keygen -t rsa -f /etc/ssh/ssh_host_rsa_key -N ""
ssh-keygen -t dsa -f /etc/ssh/ssh_host_dsa_key -N ""
ssh-keygen -t ecdsa -f /etc/ssh/ssh_host_ecdsa_key -N ""
將生成的 ssh_host_rsa_key 、 ssh_host_dsa_key 和 ssh_host_ecdsa_key 拷貝到 /usr/local/etc
chmod 600 ssh_host_*
#如果開發板需要 ssh_host_key 的話,執行:
#ssh-keygen -t rsa1 -f /etc/ssh/ssh_host_key -N ""
如果出現 privilege separation user sshd 問題:
在 /etc/passwd 增加以下:
sshd:x:74:74:Privilege-separated SSH:/var/empty/sshd:/sbin/nologin
或者修改 /etc/ssh/sshd_config (這會降低ssh的安全性):
UsePrivilegeSeparation yes 改成 UsePrivilegeSeparation no
測試:
/usr/sbin/sshd
用 ps ax 查看 sshd 是否運行
ssh root登錄:
修改 sshd_config
PermitRootLogin yes
StrictModes yes
PermitEmptyPasswords yes
修改 ssh_config
StrictHostKeyChecking no
重啟系統 reboot
設置ssh開機自啟動:
在/etc/init.d/S90app
添加:/usr/sbin/sshd