使用qemu的nat方式登录
使用qemu模拟一个运行ubuntu20.04的aarch64位的开发板,使用nat网络,然后通过端口映射的方式在host上使用ssh登录开发板。
#!/bin/bash
QEMU=qemu-system-aarch64
sudo $QEMU\
-M virt,gic-version=3,virtualization=on,type=virt \
-cpu cortex-a57 -nographic -smp 4 -m 4096 \
-fsdev local,security_model=passthrough,id=fsdev0,path=/home/pengdonglin/data0/Qemu/share \
-device virtio-9p-pci,id=fs0,fsdev=fsdev0,mount_tag=hostshare \
-drive if=none,file=./ubuntu.img,format=raw,id=hd0 -device virtio-blk-device,drive=hd0 \
-append "noinitrd root=/dev/vda1 rootfstype=ext4 rw console=ttyAMA0" \
-kernel ./linux5.8/out_arm64/arch/arm64/boot/Image \
-netdev user,id=eth0,hostfwd=tcp::8765-:22 -device virtio-net-device,netdev=eth0 \
-nographic
开发板上的ubuntu的网络配置的是dhcp:(https://www.cnblogs.com/pengdonglin137/articles/15002046.html)
pengdl@localhost:~$ cat /etc/systemd/network/80-dhcp.network
[Match]
Name=eth0
[Network]
DHCP=yes
在host上登录开发板:
#!/bin/bash
sshpass -p " " ssh pengdl@localhost -p 8765
完。
本文来自博客园,作者:摩斯电码,未经同意,禁止转载