arm开发板想要使用ssh功能传输文件,需要自己移植该功能。
可以使用提供的工具,直接移植到板子上。具体的编译过程,在最后介绍。
网盘链接:
链接:https://pan.baidu.com/s/1gfaVyQf 密码:0nw6
一、移植
1、系统起来后。新建以下目录。
mkdir /usr/local/
mkdir /usr/lcoal/etc/
mkdir /usr/local/bin/
mkdir /usr/libexec
2、把工具下载下来,搞到U盘上。使用挂载命令挂载。
mount /dev/sda1 /mnt/disk
进入U盘挂载的盘符。进入工具文件夹。
cd local/etc/
cp -r * /usr/local/etc/
cd ../bin/
cp -r * /usr/local/bin/
cd ../../libexec/
cp -r * /usr/libexec/
3、修改文件、修改权限
cd /usr/local/etc/
chmod 600 *
注意这里要使用600权限。其他权限会报错。
cd /etc/
vi passwd
使用vim编译器打开passwd文件,并在最后添加如下两行代码:
sshd:x:74:74:Privilege-separated
SSH:/var/empty/sshd:/sbin/nologin
保存退出。
4、修改root密码
passwd root
连续两次输入密码。效果如下。
passwd root
Changing password for root
New password:
Bad password: too weak
Retype password:
Password for root changed by root
5、查看开发板ip和主机是不是在同一网段。
vi /etc/eth0-setting
如不一样,修改后保存退出。重启。相同的话直接验证。
reboot
6、验证
使用网线连接开发板和路由器或者主机。并保证开发板和主机可以相互ping通。
/usr/local/bin/sshd
使用上面命令的话,会有如下打印:
/usr/local/bin/sshd
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@ WARNING: UNPROTECTED PRIVATE KEY FILE! @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Permissions 0755 for '/usr/local/etc/ssh_host_key' are too open.
It is recommended that your private key files are NOT accessible by others.
This private key will be ignored.
bad permissions: ignore key: /usr/local/etc/ssh_host_key
Could not load host key: /usr/local/etc/ssh_host_key
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@ WARNING: UNPROTECTED PRIVATE KEY FILE! @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Permissions 0755 for '/usr/local/etc/ssh_host_rsa_key' are too open.
It is recommended that your private key files are NOT accessible by others.
This private key will be ignored.
bad permissions: ignore key: /usr/local/etc/ssh_host_rsa_key
Could not load host key: /usr/local/etc/ssh_host_rsa_key
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@ WARNING: UNPROTECTED PRIVATE KEY FILE! @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Permissions 0755 for '/usr/local/etc/ssh_host_dsa_key' are too open.
It is recommended that your private key files are NOT accessible by others.
This private key will be ignored.
bad permissions: ignore key: /usr/local/etc/ssh_host_dsa_key
Could not load host key: /usr/local/etc/ssh_host_dsa_key
Disabling protocol version 1. Could not load host key
Disabling protocol version 2. Could not load host key
sshd: no hostkeys available -- exiting.
再次修改一下权限,然后继续使用刚才的命令。
chmod 600 /usr/local/etc/*
/usr/local/bin/sshd
此时效果如下:
/usr/local/bin/sshd
Disabling protocol version 1. Could not load host key
虽然有一个报错。但此时使用ssh连接开发板,可以连接。并正常使用。
移植完成。
(这个报错不清楚怎么解决了。如果有知道的大神,还望不吝赐教。1260347644@qq.com)
二、编译
刚才使用的文件都是根据源码编译出来的。下面介绍一下编译过程。
ubuntu版本:12.04
编译器:arm-2009q3
cd /home/
mkdir ssh
源码上传及解压过程不叙述。
把三个源码上传到/home/ssh目录下。
1、编译zlib
cd zlib-1.2.3/
./configure --prefix=/home/ssh/install/zlib
vi Makefile
~ CC=arm-none-linux-gnueabi-gcc
~ LDSHARED=arm-none-linux-gnueabi-gcc
~ CPP=arm-none-linux-gnueabi-gcc -E
~ AR=arm-none-linux-gnueabi-ar rc
make
make install
2、编译openssl
cd openssl-0.9.8h/
./Configure --prefix=/home/ssh/install/openssl os/compiler:arm-none-linux-gnueabi-gcc
make
make install
3、编译openssh
cd openssh-4.6p1/
./configure --host=arm-none-linux-gnueabi --with-libs --with-zlib=/home/ssh/install/zlib --with-ssl-dir=/home/ssh/install/openssl --disable-etc-default-login CC=arm-none-linux-gnueabi-gcc AR=arm-none-linux-gnueabi-ar
make
注意。运行命令时,注意参数空格。另,openssh不需要make install。
在当前目录下,
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 ""
ssh-keygen -t dsa -f ssh_host_key -N ""
使用以上五条命令。会生成五个文件。
4、拷贝文件
mkdir /home/ssh/usr/
mkdir /home/ssh/usr/local/
mkdir /home/ssh/usr/local/etc/
mkdir /home/ssh/usr/local/bin/
mkdir /home/ssh/usr/libexec/
之所以新建以上几个文件夹是为了好对应。
cd /home/ssh/openssh-4.6p1/
cp ssh_host*_key /home/ssh/usr/local/etc/
cp scp sftp ssh sshd ssh-add ssh-agent ssh-keygen ssh-keyscan /home/ssh/usr/local/bin/
cp moduli ssh_config sshd_config /home/ssh/usr/local/etc/
cp sftp-server ssh-keysign /home/ssh/usr/libexec/
cd ../
tar -vcf usr.tar.gz usr/
生成的usr.tar.gz就是刚才使用的工具包
全部完成。
参考链接: