ssh session with qemu-arm using busybox
Hi, I have a qemu-arm setup with busybox which I normally use to test my kernel changes. I use this command to boot it: QEMU-ARM$ qemu-system-arm -M vexpress-a9 -m 1024M -kernel ../KERNEL/linux/arch/arm/boot/zImage -dtb ../KERNEL/linux/arch/arm/boot/dts/vexpress-v2p-ca9.dtb -initrd rootfs.img.gz -append "console=ttyAMA0 root=/dev/ram rdinit=/sbin/init ip=dhcp" -nographic -smp 4 This includes, my own custom kernel and rootfs build. For rootfs I use busybox and create cpio image and use it as initrd. But, every time, if I have to copy some files inside qemu, I need to create create roofs image. This is painful. So, now I am exploring how to transfer files from my ubuntu pc to qemu-session using "ssh". I know this is possible, but I am still not successful, and bit lazy to explore these. I am sure, many of you people would have explored already "how to use ssh over qemu" and found a easy method. So, if anybody have easy setup please share with me. I could see that after adding "ip=dhcp" I get the eth0 interface like this: / # ifconfig eth0 Link encap:Ethernet HWaddr 52:54:00:12:34:56 inet addr:10.0.2.15 Bcast:10.0.2.255 Mask:255.255.255.0 UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:2 errors:0 dropped:0 overruns:0 frame:0 TX packets:2 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:1180 (1.1 KiB) TX bytes:1180 (1.1 KiB) Interrupt:22 lo Link encap:Local Loopback inet addr:127.0.0.1 Mask:255.0.0.0 UP LOOPBACK RUNNING MTU:65536 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:1000 RX bytes:0 (0.0 B) TX bytes:0 (0.0 B) But I could not ping it from ubuntu PC. Regards, Pintu
Στις 2019-03-11 16:34, Pintu Agarwal έγραψε:
Hi,
I have a qemu-arm setup with busybox which I normally use to test my kernel changes. I use this command to boot it:
QEMU-ARM$ qemu-system-arm -M vexpress-a9 -m 1024M -kernel ../KERNEL/linux/arch/arm/boot/zImage -dtb ../KERNEL/linux/arch/arm/boot/dts/vexpress-v2p-ca9.dtb -initrd rootfs.img.gz -append "console=ttyAMA0 root=/dev/ram rdinit=/sbin/init ip=dhcp" -nographic -smp 4
This includes, my own custom kernel and rootfs build. For rootfs I use busybox and create cpio image and use it as initrd.
But, every time, if I have to copy some files inside qemu, I need to create create roofs image. This is painful.
So, now I am exploring how to transfer files from my ubuntu pc to qemu-session using "ssh". I know this is possible, but I am still not successful, and bit lazy to explore these.
I am sure, many of you people would have explored already "how to use ssh over qemu" and found a easy method. So, if anybody have easy setup please share with me.
I could see that after adding "ip=dhcp" I get the eth0 interface like this: / # ifconfig eth0 Link encap:Ethernet HWaddr 52:54:00:12:34:56 inet addr:10.0.2.15 Bcast:10.0.2.255 Mask:255.255.255.0 UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:2 errors:0 dropped:0 overruns:0 frame:0 TX packets:2 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:1180 (1.1 KiB) TX bytes:1180 (1.1 KiB) Interrupt:22
lo Link encap:Local Loopback inet addr:127.0.0.1 Mask:255.0.0.0 UP LOOPBACK RUNNING MTU:65536 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:1000 RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
But I could not ping it from ubuntu PC.
Regards, Pintu
_______________________________________________ linux-riscv mailing list linux-riscv@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-riscv
You may use the hostfw argument on qemu, e.g... -netdev user,id=unet,hostfwd=tcp::2222-:22 \ -net user \ and you 'll get guest's port 22 to be forwarded to hosts port 2222, so you can do ssh root@localhost:2222 from the host. Regards, Nick
-netdev user,id=unet,hostfwd=tcp::2222-:22 \ -net user \
and you 'll get guest's port 22 to be forwarded to hosts port 2222, so you can do
ssh root@localhost:2222
from the host.
I tried many different options, but unfortunately none worked for me. 1) qemu-system-arm -M vexpress-a9 -m 1024M -kernel ../KERNEL/linux/arch/arm/boot/zImage -dtb ../KERNEL/linux/arch/arm/boot/dts/vexpress-v2p-ca9.dtb -initrd rootfs.img.gz -append "console=ttyAMA0 root=/dev/ram rdinit=/sbin/init ip=dhcp" -nographic -smp 4 -netdev user,id=unet,hostfwd=tcp::2222-:22 -net user With this the eth0 interface is removed, and I see this message (although login works): qemu-system-arm: warning: hub 0 with no nics qemu-system-arm: warning: netdev unet has no peer Booting Linux on physical CPU 0x0 <skip> NET: Registered protocol family 17 <skip> Run /sbin/init as init process ifconfig: SIOCSIFADDR: No such device route: SIOCADDRT: Network is unreachable But, ssh is still not working. ssh root@localhost:2222 ssh: Could not resolve hostname localhost:2222: Name or service not known 2) if I give "-net nic" I get eth0 interface but still ssh does not work. qemu-system-arm: warning: netdev unet has no peer Booting Linux on physical CPU 0x0 3) With this there is no error, but still ssh not working qemu-system-arm -M vexpress-a9 -m 1024M -kernel ../KERNEL/linux/arch/arm/boot/zImage -dtb ../KERNEL/linux/arch/arm/boot/dts/vexpress-v2p-ca9.dtb -initrd rootfs.img.gz -append "console=ttyAMA0 root=/dev/ram rdinit=/sbin/init" -nographic -netdev user,id=net0,hostfwd=tcp::2222-:22 -device virtio-net-device,netdev=net0 -net user -net nic ssh root@localhost:2222 ssh: Could not resolve hostname localhost:2222: Name or service not known 4) I also followed the steps mentioned in the below document, but its same result: https://wiki.qemu.org/Documentation/Networking ------------- So, I have some doubts: - Do, I need anything to be configured on host PC as well ? I am using Ubuntu 16.04 desktop, and it is connected to only one office LAN network - Do I need any network configuration changes on host ? - Do I need to enable any thing in kernel side ? - I am using minimal busybox and I see there is no "ssh" command there. Do I need a different busybox or a dropbear ? - Will it work easily with buildroot ? - Is there any precompiled arm32-rootfs image present somewhere, which which ssh can work by default ? Because, I really don't care much about user side, so any arm-rootfs should be fine for me - I haven't really explored "bridge/tap" network yet. Is that worth to try in these conditions. Regards, Pintu
On 12/03/2019 14:02, Pintu Agarwal wrote:
-netdev user,id=unet,hostfwd=tcp::2222-:22 \ -net user \
and you 'll get guest's port 22 to be forwarded to hosts port 2222, so you can do
ssh root@localhost:2222
from the host.
I tried many different options, but unfortunately none worked for me. 1) qemu-system-arm -M vexpress-a9 -m 1024M -kernel ../KERNEL/linux/arch/arm/boot/zImage -dtb ../KERNEL/linux/arch/arm/boot/dts/vexpress-v2p-ca9.dtb -initrd rootfs.img.gz -append "console=ttyAMA0 root=/dev/ram rdinit=/sbin/init ip=dhcp" -nographic -smp 4 -netdev user,id=unet,hostfwd=tcp::2222-:22 -net user
With this the eth0 interface is removed, and I see this message (although login works): qemu-system-arm: warning: hub 0 with no nics qemu-system-arm: warning: netdev unet has no peer Booting Linux on physical CPU 0x0 <skip> NET: Registered protocol family 17 <skip> Run /sbin/init as init process ifconfig: SIOCSIFADDR: No such device route: SIOCADDRT: Network is unreachable
But, ssh is still not working. ssh root@localhost:2222 ssh: Could not resolve hostname localhost:2222: Name or service not known
man ssh + Make sure you have sshd in your custom rootfs and has been stared. Cheers Suzuki
On Mon, 11 Mar 2019, Pintu Agarwal wrote:
I am sure, many of you people would have explored already "how to use ssh over qemu" and found a easy method. So, if anybody have easy setup please share with me.
I could see that after adding "ip=dhcp" I get the eth0 interface like this: / # ifconfig eth0 Link encap:Ethernet HWaddr 52:54:00:12:34:56 inet addr:10.0.2.15 Bcast:10.0.2.255 Mask:255.255.255.0 UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:2 errors:0 dropped:0 overruns:0 frame:0 TX packets:2 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:1180 (1.1 KiB) TX bytes:1180 (1.1 KiB) Interrupt:22
lo Link encap:Local Loopback inet addr:127.0.0.1 Mask:255.0.0.0 UP LOOPBACK RUNNING MTU:65536 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:1000 RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
But I could not ping it from ubuntu PC.
This should already be documented here: https://wiki.qemu.org/Documentation/Networking The default QEMU network is -net user slirp based networking that provides outbound connectivity from the virtual machine but no ping or inbound connections. I.e. you can ssh from your guest to your host (so you could use scp in your guest to copy files from your host) or use some other networking (such as tap) that allows the host to connect to guest (but then you'll need to arrange routing and dhcp if you want that on your host otherwise your guest will only see your host). Hope this helps. Regards, BALATON Zoltan
participants (4)
-
BALATON Zoltan -
Nick Kossifidis -
Pintu Agarwal -
Suzuki K Poulose