1. 简介
ssh是远程登陆的一种,在服务器端开启sshd,远程就可以通过ssh协议登陆服务器。同ssh一起的自带sftp子线程,可以实现文件的传送。ssh 同 telnet 相比,是一种加密传输,相对安全。
2. 移植
2.1 编译zlib
./configure --prefix=/home/ohehe/wor_lip/porting/ssh/install/zlib CC="arm-fsl-linux-gnueabi-gcc -march=armv7-a -mfloat-abi=hard -mfpu=neon -mtune=cortex-a7 --sysroot=/home/ohehe/ls1021-toolchain/sysroots/cortexa7hf-vfp-neon-fsl-linux-gnueabi" AR="arm-fsl-linux-gnueabi-ar -march=armv7-a -mfloat-abi=hard -mfpu=neon -mtune=cortex-a7 --sysroot=/home/ohehe/ls1021-toolchain/sysroots/cortexa7hf-vfp-neon-fsl-linux-gnueabi"
更改Makefile中的 CC
arm-fsl-linux-gnueabi-gcc -march=armv7-a -mfloat-abi=hard -mfpu=neon -mtune=cortex-a7 --sysroot=/home/ohehe/ls1021-toolchain/sysroots/cortexa7hf-vfp-neon-fsl-linux-gnueabi
AR为arm-fsl-linux-gnueabi-ar
所有gcc更改成$(CC)
make
make install
2.2 编译openssl
./Configure --prefix=/home/ohehe/wor_lip/porting/ssh/install/openssl os/compiler:arm-fsl-linux-gnueabi-gcc
更改Makefile中CC
变成
CC= arm-fsl-linux-gnueabi-gcc -march=armv7-a -mfloat-abi=hard -mfpu=neon -mtune=cortex-a7 --sysroot=/home/ohehe/ls1021-toolchain/sysroots/cortexa7hf-vfp-neon-fsl-linux-gnueabi
2.3 编译ssh
./configure --host=arm-linux --prefix=/home/ohehe/wor_lip/porting/ssh/install/openssh --with-libs --with-zlib=/home/ohehe/wor_lip/porting/ssh/install/zlib --with-ssl-dir=/home/ohehe/wor_lip/porting/ssh/install/openssl --disable-etc-default-login CC=" arm-fsl-linux-gnueabi-gcc -march=armv7-a -mfloat-abi=hard -mfpu=neon -mtune=cortex-a7 --sysroot=/home/ohehe/ls1021-toolchain/sysroots/cortexa7hf-vfp-neon-fsl-linux-gnueabi" AR=arm-fsl-linux-gnueabi-ar
make
手动将编译出来的文件拷贝到安装路径下
mkdir -p /home/ohehe/wor_lip/porting/ssh/install/openssh/usr/local/bin/
mkdir -p /home/ohehe/wor_lip/porting/ssh/install/openssh/usr/local/
mkdir -p /home/ohehe/wor_lip/porting/ssh/install/openssh/usr/local/etc/
mkdir -p /home/ohehe/wor_lip/porting/ssh/install/openssh/usr/libexec/
mkdir -p /home/ohehe/wor_lip/porting/ssh/install/openssh/usr/sbin/
mkdir -p /home/ohehe/wor_lip/porting/ssh/install/openssh/bin
cp scp sftp ssh ssh-add ssh-agent ssh-keygen ssh-keyscan moduli ssh_config sshd_config sftp-server ssh-keysign sshd /home/ohehe/wor_lip/porting/ssh/install/openssh/bin -a
cp scp sftp ssh ssh-add ssh-agent ssh-keygen ssh-keyscan /home/ohehe/wor_lip/porting/ssh/install/openssh
cp moduli ssh_config sshd_config /home/ohehe/wor_lip/porting/ssh/install/openssh/usr/local/
cp moduli ssh_config sshd_config /home/ohehe/wor_lip/porting/ssh/install/openssh/usr/local/etc/
cp sftp-server ssh-keysign
要有 /var/empty 文件
在文件夹 /etc/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 ""
将生成的key文件放到文件夹/etc/ssh下
更改配置文件内容 sshd_config
打开
HostKey /etc/ssh/ssh_host_rsa_key
HostKey /etc/ssh/ssh_host_dsa_key
HostKey /etc/ssh/ssh_host_ecdsa_key
HostKey /etc/ssh/ssh_host_ed25519_key
更改,允许root用户登录
PermitRootLogin yes
允许无密码登录
PermitEmptyPasswords yes
另外
sshd放入
新建文件夹 /usr/local/openssh/bin
将相关可执行文件放入上边那个文件夹下
改动 /etc/profile 中的 PATH,后边追加:/usr/local/openssh/bin
在start_program.sh中添加
/usr/local/openssh/bin/sshd -f /etc/ssh/sshd_config