I started arch linux in a qemu vm with guest port 22 connected to host port 60022, set the root password in the guest, and edited the sshd config in the guest to allow root logins and set the log level to debug. Then I started sshd on the guest and tried to log into the guest from the host using ssh [email protected] -p 60022 -vvv
.
Nothing happens.
journalctl -xe
on the guest reveals sshd is started and listening on guest port 22, but does not say anything at all about an attempted connection. On the host, -vvv
gives a lot of output, but it clearly tells me it connects to the guest, lists its id files and version, and then waits two minutes before saying kex_exchange_identification: read: Connection reset by peer
and giving up. Again, the guest journalctl doesn't report any connection attempt.
I can ping external websites from the guest, so I know the internet is set up correctly. I have no idea what the purpose of the abomination journalctl is when log files already existed.
ssh
immediately fails if I try to connect to port 60021 or any port besides 60022, instead of waiting 2 minutes, plus on 60022 it shows "Connection established" in the -vvv
output, so I know the host is probably connecting to the guest. But the guest sshd is not working very hard because it won't even immediately reject usernames besides root that don't exist.
My full qemu command is
qemu-system-x86_64 -netdev user,id=n0 -device rtl8139,netdev=n0 -enable-kvm -machine q35,accel=kvm -device intel-iommu -cpu host,hv_relaxed,hv_spinlocks=0x1fff,hv_vapic,hv_time -nic user,hostfwd=tcp::60022-:22 -m 8G -smp 2 -cdrom ~/Downloads/archlinux-2020.09.01-x86_64.iso ~/vmimgs/lfs.qcow2
How can I ssh into my virtual machine? (See also this question from about 4 years ago where a user had the same problem but with virtualbox and no solution was given.)