参考网页:https://www.cnblogs.com/hongzhunzhun/p/7241192.html
openssh http://www.openssh.com/portable.html
openssl http://www.openssl.org/source
zlib http://www.zlib.net/
mkdir /work/ssh -p
cd ssh
mkdir compress install source
(解压包在compressed目录下)
cd /work/ssh/source/
tar -xvf ../compressed/zlib-1.2.1.2.tar.gz
unzip ../compressed/openssl-OpenSSL_0_9_6-stable.zip
tar -xvf ../compressed/openssh-5.2p1.tar.gz
mv zlib-1.2.1.2 zlib
mv openssl-OpenSSL_0_9_6-stable openssl
mv openssh-5.2p1 openssh
cd /work/ssh/source/zlib
./configure --prefix=/work/ssh/install/zlib
修改Makefile,不然编译不对
vim Makefile
CC=arm-linux-gnueabi-gcc
AR=arm-linux-gnueabi-ar rc
CPP =arm-linux-gnueabi-gcc -E
LDSHARED=arm-linux-gnueabi-gcc
make
make install
cd /work/ssh/source/openssl
./Configure --prefix=/work/ssh/install/openssl os/compiler:arm-linux-gnueabi-gcc
make
make install
cd /work/ssh/source/ openssh-4.6p1
./configure --host=arm-none-linux-gnueabi --with-libs --with-zlib=/work/ssh/install/zlib-1.2.11 --with-ssl-dir=/work/ssh/install/openssl-0.9.8e --disable-etc-default-login CC=arm-none-linux-gnueabi-gcc AR=arm-none-linux-gnueabi-ar
make
openssh不需要make install
参考网页:https://blog.csdn.net/weixin_43549602/article/details/84025910
mkdir /work/ssh/transplant/sbin -p
mkdir /work/ssh/transplant/bin
mkdir /work/ssh/transplant/usr/local/openssh/bin -p
mkdir /work/ssh/transplant/usr/local/openssh/etc
mkdir /work/ssh/transplant/usr/local/libexec
cp /work/ssh/install/{
scp,sftps,sh,ssh-add,ssh-agent,ssh-keygen,ssh-keyscan} /work/ssh/transplant/usr/local/openssh/bin
cp /work/ssh/install/{
sshd_config,ssh_config} /work/ssh/transplant/usr/local/openssh/etc
cp /work/ssh/install/{
sshd} /work/ssh/transplant/sbin
cp /work/ssh/install/{
sftp-server,ssh-keysign} /work/ssh/transplant/usr/local/libexec
cd /work/ssh/bin
ln -s /usr/local/openssh/bin/scp
ln -s /usr/local/openssh/bin/sftp
ln -s /usr/local/openssh/bin/ssh
ln -s /usr/local/openssh/bin/ssh-add
ln -s /usr/local/openssh/bin/ssh-agent
ln -s /usr/local/openssh/bin/ssh-keygen
ln -s /usr/local/openssh/bin/ssh-keyscan
cd ../
tar -cvf openssh_exe.bin ./
将openssh.bin拷贝到开发板,然后再根目录解压,我是拷贝到了/opt/下
cd /
tar -xvf /opt/openssh.bin
openssh_exe.tar.gz直接解压到开发板的根目录。
新增组1002和用户sshd,如下:
~# vi /etc/passwd
(添加下面这行)
sshd:x:1002:1002::/home/sshd:/bin/sh
~# vi /etc/group
(添加下面这行)
sshd:x:1000:sshd
因为我用的a33的板子密码不是直接在passwd文件中,而是保存在shadow目录下的,其中默认密码的格式直接抄文件内别的用户的格式就可以了
我添加的内容如下:
vi /etc/shadow
添加如下内容:
sshd::10933:0:099999:7:::
还要新建home目录下的sshd文件夹
并且让它属于sshd
mkdir /home/sshd
chown sshd /home/sshd
最后确认一下自己是否成功创建了sshd
[root@dragonboard /home]# passwd sshd
Changing password for sshd
New password:
Bad password: too short
Retype password:
Password for sshd changed by root
[root@dragonboard /home]#
[root@dragonboard /home]#
~ # cd /usr/local/etc/
/usr/local/etc # ssh-keygen -t rsa -f ssh_host_rsa_key -N ""
/usr/local/etc # ssh-keygen -t dsa -f ssh_host_dsa_key -N ""
/usr/local/etc # ssh-keygen -t dsa -f ssh_host_ed25519_key -N ""
/usr/local/openssh/etc/sshd_config留作备份,实际使用的/usr/local/etc/sshd_config
[root@dragonboard local]# cp /usr/local/openssh/* ./
[root@dragonboard local]# rm sshd_config
[root@dragonboard local]# vi sshd_config
sshd_config修改如下:
PermitRootLogin yes
Protocol 2
HostKey /usr/local/etc/ssh_host_rsa_key
HostKey /usr/local/etc/ssh_host_dsa_key
HostKey /usr/local/etc/ssh_host_ed25519_key
PubkeyAuthentication yes
PasswordAuthentication yes
PermitEmptyPasswords no
AllowUsers sshd root
Subsystem sftp internal-sftp
Match group 1002
ChrootDirectory /home/sshd
X11Forwarding no
AllowTcpForwarding no
ForceCommand internal-sftp
~~
运行sshd
/sbin/sshd
到这里就可以使用sshd了,但是密码认证因为配置的板子没有办法使用ecdsa,所以没有办法直接登录,需要用下面的办法,无密码登录
这个百度直接就可以查到相关的介绍
这里我给的参考是这个:https://jingyan.baidu.com/article/cbcede076bc84302f50b4d4c.html
具体步骤如下:
在虚拟机和开发板分别输入命令创造密钥
ssh-keygen
输入这个命令以后,之后需要几个选项,直接回车就可以
然后将虚拟机的id_rsa.pub 里面的内容拷贝放到 开发板的authorized_keys文件当中
开发板可能没有authorized_keys这个文件,直接自己创建
然后把虚拟机的id_rsa.pub的内容复制进来就可以了
这个文件在~/.ssh 这个目录当中
最后复制开发板的authorized_keys内容,到虚拟机当中就可以了
最后效果如下:
rootl@ubuntu:~$ su root
密码:
root@ubuntu:/home/rootl# cd ~/.ssh/
root@ubuntu:~/.ssh# cat authorized_keys
ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEA5f0qvQCvjtEejl6WpXiGz+Q9OJDFAgX4Dj4kHLQt3HpIF/bDua92TngzmPlDkF1TcLg4WU2rA27i9aKLtZLMq2b2E+g+MsIr3zix/8WNeZkTpKXTmNeeR6DJDVN8u3lq5KEogocApHSp12dpfnyhecppfzBCrTx4XqxML8ai1dvDb0sHZ+uK8zpY+gY1+F4R8FDcagBmyDvUZMUzS6eYFqKVggroDcUyXGcUYs+b5qzvVxGUaMqsbeEgro8c+AZQEeOTbqwyHDRBQlxVxF1hoES8jFC/fJ40yTMo1G5+d5Pa9lUR9tL7Grc2vhNrafLrh5aih3by20igr599SIaSkw== root@dragonboard
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQDd601R6+us65dUbt2StJGHjI7/7+5akwrHxUdZtd4iJ8pLPNDj96SjGDwTgoWfr/t05vF61G1HxRhNAl9/YEfyg09xyNO9yPM1Q1UH1I2rxDrDUkbtKq0gdXmljkBo/2Dj4Ums+x4ew7JXnpAv5RK1c8GcY+IlLjUSctIxRfCePD2UKizujpHMM8VmZe5Tbc+Z3K6j5S3z+sKUv1Eo93JG3H3N3vhy/71TxMFONPdZnDl1F/+L47JDEX1wD50NOYIvRLhWAUoZ24xAOrJ0SrL2gus5qTcMtca0Rm8ryMolx1WE8aDdlVkuvAeyUs9w8Zg7/35KxImkjPelhnr3XS7Gn+ALgQdX1T6UJAOAoh68P98aeNuMAtBs6Zviq1LyV1mRl2w/6xmyG/1MhdOufmv+1Wzo8svYwgeZupq9xoR8c24QpBxFtco341CB6ZY09hiNsKa2BqcPLLlgHUaNk6MoUNoJhf6Mbw3QCJCmht+xM18QQkDg6nl0vJvHenX0xFs= root@ubuntu
root@ubuntu:~/.ssh#
[root@dragonboard local]# cd /root/.ssh/
[root@dragonboard .ssh]# cat authorized_keys
ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEA5f0qvQCvjtEejl6WpXiGz+Q9OJDFAgX4Dj4kHLQt3HpIF/bDua92TngzmPlDkF1TcLg4WU2rA27i9aKLtZLMq2b2E+g+MsIr3zix/8WNeZkTpKXTmNeeR6DJDVN8u3lq5KEogocApHSp12dpfnyhecppfzBCrTx4XqxML8ai1dvDb0sHZ+uK8zpY+gY1+F4R8FDcagBmyDvUZMUzS6eYFqKVggroDcUyXGcUYs+b5qzvVxGUaMqsbeEgro8c+AZQEeOTbqwyHDRBQlxVxF1hoES8jFC/fJ40yTMo1G5+d5Pa9lUR9tL7Grc2vhNrafLrh5aih3by20igr599SIaSkw== root@dragonboard
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQDd601R6+us65dUbt2StJGHjI7/7+5akwrHxUdZtd4iJ8pLPNDj96SjGDwTgoWfr/t05vF61G1HxRhNAl9/YEfyg09xyNO9yPM1Q1UH1I2rxDrDUkbtKq0gdXmljkBo/2Dj4Ums+x4ew7JXnpAv5RK1c8GcY+IlLjUSctIxRfCePD2UKizujpHMM8VmZe5Tbc+Z3K6j5S3z+sKUv1Eo93JG3H3N3vhy/71TxMFONPdZnDl1F/+L47JDEX1wD50NOYIvRLhWAUoZ24xAOrJ0SrL2gus5qTcMtca0Rm8ryMolx1WE8aDdlVkuvAeyUs9w8Zg7/35KxImkjPelhnr3XS7Gn+ALgQdX1T6UJAOAoh68P98aeNuMAtBs6Zviq1LyV1mRl2w/6xmyG/1MhdOufmv+1Wzo8svYwgeZupq9xoR8c24QpBxFtco341CB6ZY09hiNsKa2BqcPLLlgHUaNk6MoUNoJhf6Mbw3QCJCmht+xM18QQkDg6nl0vJvHenX0xFs= root@ubuntu
[root@dragonboard .ssh]#
虚拟机中输入:
root@ubuntu:~/.ssh# ssh [email protected]
The authenticity of host '192.168.1.144 (192.168.1.144)' can't be established.
RSA key fingerprint is SHA256:S7vjVkvKMWID964pfnlRP2WdCtittpIgpfv0rh7fA+o.
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
Warning: Permanently added '192.168.1.144' (RSA) to the list of known hosts.
-sh: exprot: not found
nand activated #1
insmod: can't insert '/lib/modules/3.4.39/nand.ko': File exists
camera activated #1
camera activated
camera module insmod done
camera activated #1
camera activated
insmod: can't insert '/lib/modules/3.4.39/videobuf-core.ko': File exists
insmod /lib/modules/3.4.39/videobuf-core.ko failed
mount: mounting /dev/mmcblk0p8 on /data failed: Invalid argument
insmod: can't insert '/system/vendor/modules/mma7660.ko': Operation not permitted
insmod: can't insert '/system/vendor/modules/bcmdhd.ko': No such device
grep: /sys/class/input/event4/device/name: No such file or directory
mainwindow: error while loading shared libraries: libQtGui.so.4: cannot open shared object file: No such file or directory
[root@dragonboard /root]#
[root@dragonboard /root]#
[root@dragonboard /root]#
主要试错关键点:
1.板子和虚拟机能不能ping通
2.板子和虚拟机能不能打开sshd
3.虚拟机单独能不能被putty的ssh登陆进去
如果可以登录进去就说明ssh是可以使用的,接下来只要配置好Qt就可以满足正常调试的需求了,但是Qt如果想要进入Debug模式,还要重新编译配置gdbserver给开发板,然后在虚拟机配置GDB才能运行调试模式,我这里都会总结一下教程内容。
在选项中,左侧菜单找到设备,然后再设备界面中输入开发板的相关信息
1.开发板的ip,后面的端口就要22,空闲端口默认就可以,也不用动
2.用户名称,应该要改为root
然后选择左侧的Kits ,再自己套件中加入刚才设置好的设备
这样就可以在Qt编辑程序,然后直接在开发板运行了。
但是如果想要进入调试模式,还是需要再麻烦几步,首先是编译安装gdbserver,然后放到开发板的目录当中安装“apt-get install gdb-multiarch”,并且在Debugger中配置就可以了