不能 SSH/SCP 连接到基于 Qemu 的 powerpc VM



我想将文件传输到基于QEMU的PowerPC VM(模拟飞思卡尔的MPC8544DS)。我使用 buildroot 来构建内核和 rootfs。我像这样调用虚拟机:

qemu-system-ppc -nographic -M mpc8544ds -m 512 -kernel ~/CrossCompilation/zImage -hda ~/CrossCompilation/rootfs.cpio -append "root=/dev/sda rw" -redir tcp:2222::22

但是我无法传输文件,并且它抛出了以下日志和错误:

Executing: program /usr/bin/ssh host localhost, user root, command scp -v -t ~/.
OpenSSH_6.0p1 Debian-4+deb7u2, OpenSSL 1.0.1e 11 Feb 2013
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: Applying options for *
debug1: Connecting to localhost [::1] port 2222.
debug1: connect to address ::1 port 2222: Connection refused
debug1: Connecting to localhost [127.0.0.1] port 2222.
debug1: Connection established.
debug1: identity file ~/.ssh/id_rsa type -1
debug1: identity file ~/.ssh/id_rsa-cert type -1
debug1: identity file ~/.ssh/id_dsa type -1
debug1: identity file ~/.ssh/id_dsa-cert type -1
debug1: identity file ~/.ssh/id_ecdsa type -1
debug1: identity file ~/.ssh/id_ecdsa-cert type -1
ssh_exchange_identification: Connection closed by remote host
lost connection

我假设由于我的 VM 似乎没有任何物理网络适配器,因此无法联网。所以我像这样调用 QEMU:

/qemu-system-ppc -nographic -M mpc8544ds -m 512 -kernel ~/CrossCompilation/zImage -hda ~/CrossCompilation/rootfs.cpio -netdev user,id=network0 -device e1000,netdev=network0 -append "root=/dev/sda rw" -redir tcp:2222::22

没有运气。事实上,这样做甚至不会添加任何新的物理以太网适配器(正如我所想的那样)。与以前一样,唯一的"实时"适配器是环回适配器。

ifconfig
lo    Link encap:Local Loopback
      inet addr:127.0.0.1  Mask:255.0.0.0
      inet6 addr: ::1/128 Scope:Host
      UP LOOPBACK RUNNING  MTU:16436  Metric:1
      RX packets:0 errors:0 dropped:0 overruns:0 frame:0
      TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
      collisions:0 txqueuelen:0
      RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

我早些时候的印象是,也许这种情况正在发生,因为 VM 上没有运行 ssh deamon,因此我Dropbear添加到目标包列表中,它在 VM 启动时启动(它显示为启动日志的一部分)。然而,它以同样的错误失败了。 所以显然这似乎不是罪魁祸首。

我不确定它是否与我的 VM 上的网络设置有关,或者可能需要将某些内容添加到 rootfs(busybox)中。

等着听。

如果您没有网络适配器,最好的办法是挂载共享驱动器。本页包含有关使用 ARM1176JZF-S 系统创建和修改磁盘的一些信息:

http://xecdesign.com/working-with-qemu/

在 Buildroot 2016.05、QEMU 2.5.0 x86_64、Ubuntu 16.04 主机上进行测试

我不喜欢 ppc,但这应该在那里也有效。如果没有,请告诉我。

qemu_x86_64_defconfig开始并启用 openssh 包。

从以下方面启动 QEMU:

qemu-system-x86_64 
  -M pc 
  -append root=/dev/vda 
  -drive file=output/images/rootfs.ext2,if=virtio,format=raw 
  -enable-kvm 
  -kernel output/images/bzImage 
  -m 512 
  -net nic,model=virtio 
  -net user,hostfwd=tcp::2222-:22

然后在客人身上:

vi /etc/ssh/sshd_config

修改以下设置:

PermitRootLogin yes
PermitEmptyPassword yes

并重新启动服务器:

/etc/init.d/50sshd restart

正是因为这个文件存在,所以 sshd 默认启动。

然后从主机:

ssh root@localhost -p 2222

如果发生故障,还要检查来宾上的服务器日志:

less /var/log/messages

然后在最终系统上,您应该使用 BR2_ROOTFS_OVERLAYBR2_ROOTFS_POST_BUILD_SCRIPT 自动创建该日志文件:https://buildroot.org/downloads/manual/manual.html#rootfs-custom

最新更新