0

I am using Ubuntu 18.04.2 in both host and guest machine. I have created the virtual machine using libvirt. During VM creation I did not establish ssh from host to guest using libvirt. I am trying to run VM with following Qemu command. I added the hostfwd in the command to ssh to guest. I have set up the ssh server in guest. But I cannot connect to guest from host using ssh. How can I solve the issue?

sudo qemu-system-x86_64 \
    -enable-kvm \
    -name guest=ubuntu18.04_VM_libvirt,debug-threads=on \
    -S \
    -machine pc-i440fx-bionic,accel=kvm,usb=off,vmport=off,dump-guest-core=off \
    -cpu Broadwell-noTSX-IBRS \
    -m 4096 \
    -realtime mlock=off \
    -smp 6,sockets=6,cores=1,threads=1 \
    -uuid ec642fe5-8e5c-4d4a-ada7-b8562396d477 \
    -no-user-config \
    -nodefaults \
    -chardev socket,id=charmonitor,path=/home/probir/Downloads/qemu_with_libvirt/monitor.sock,server,nowait \
    -mon chardev=charmonitor,id=monitor,mode=control \
    -rtc base=utc,driftfix=slew \
    -global kvm-pit.lost_tick_policy=delay \
    -no-hpet \
    -no-shutdown \
    -global PIIX4_PM.disable_s3=1 \
    -global PIIX4_PM.disable_s4=1 \
    -boot strict=on \
    -device ich9-usb-ehci1,id=usb,bus=pci.0,addr=0x5.0x7 \
    -device ich9-usb-uhci1,masterbus=usb.0,firstport=0,bus=pci.0,multifunction=on,addr=0x5 \
    -device ich9-usb-uhci2,masterbus=usb.0,firstport=2,bus=pci.0,addr=0x5.0x1 \
    -device ich9-usb-uhci3,masterbus=usb.0,firstport=4,bus=pci.0,addr=0x5.0x2 \
    -device virtio-serial-pci,id=virtio-serial0,bus=pci.0,addr=0x6 \
    -drive file=/home/probir/Downloads/qemu_with_libvirt/ubuntu18.04.img,format=raw,if=none,id=drive-virtio-disk0 \
    -device virtio-blk-pci,scsi=off,bus=pci.0,addr=0x7,drive=drive-virtio-disk0,id=virtio-disk0,bootindex=1 \
    -drive if=none,id=drive-ide0-0-0,readonly=on \
    -device ide-cd,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0 \
    -netdev bridge,id=hostnet0,br=virbr0 \
    -device virtio-net-pci,netdev=hostnet0,id=net0,mac=52:54:00:96:2f:7a,bus=pci.0,addr=0x3 \
    -chardev pty,id=charserial0 \
    -device isa-serial,chardev=charserial0,id=serial0 \
    -chardev spicevmc,id=charchannel0,name=vdagent \
    -device virtserialport,bus=virtio-serial0.0,nr=1,chardev=charchannel0,id=channel0,name=com.redhat.spice.0 \
    -device usb-tablet,id=input0,bus=usb.0,port=1 \
    -spice port=5900,addr=127.0.0.1,disable-ticketing,image-compression=off,seamless-migration=on \
    -device qxl-vga,id=video0,ram_size=67108864,vram_size=67108864,vram64_size_mb=0,vgamem_mb=16,max_outputs=1,bus=pci.0,addr=0x2 \
    -device intel-hda,id=sound0,bus=pci.0,addr=0x4 \
    -device hda-duplex,id=sound0-codec0,bus=sound0.0,cad=0 \
    -chardev spicevmc,id=charredir0,name=usbredir \
    -device usb-redir,chardev=charredir0,id=redir0,bus=usb.0,port=2 \
    -chardev spicevmc,id=charredir1,name=usbredir \
    -device usb-redir,chardev=charredir1,id=redir1,bus=usb.0,port=3 \
    -device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x8  \
    -netdev user,id=netdev0,hostfwd=tcp:127.0.0.1:2222-:22 \
    -device virtio-net-pci,netdev=netdev0 \
    -msg timestamp=on 

After running ssh I get following error.

$sudo ssh -p2222 probir@localhost -vv
OpenSSH_7.6p1 Ubuntu-4ubuntu0.3, OpenSSL 1.0.2n  7 Dec 2017
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: Applying options for *
debug2: resolving "localhost" port 2222
debug2: ssh_connect_direct: needpriv 0
debug1: Connecting to localhost [127.0.0.1] port 2222.
debug1: Connection established.
debug1: permanently_set_uid: 0/0
debug1: key_load_public: No such file or directory
debug1: identity file /root/.ssh/id_rsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file /root/.ssh/id_rsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /root/.ssh/id_dsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file /root/.ssh/id_dsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /root/.ssh/id_ecdsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file /root/.ssh/id_ecdsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /root/.ssh/id_ed25519 type -1
debug1: key_load_public: No such file or directory
debug1: identity file /root/.ssh/id_ed25519-cert type -1
debug1: Local version string SSH-2.0-OpenSSH_7.6p1 Ubuntu-4ubuntu0.3
ssh_exchange_identification: read: Connection reset by peer
  • It seems various users had these problems in arch or Ubuntu in the past, but mostly with arm emulation. There was never a conclusion afaik, as it was never reproducible to others. Can you simplify your case to use less devices, in particular not the second network device (at least for debugging)? – Christian Ehrhardt Jul 11 at 11:29
  • I followed adam.younglogic.com/2016/08/running-qemukvm-without-libvirt to run Qemu without using libvirt. However, they modified the network connection. Originally, libvirt configures the network according to /var/lib/libvirt/dnsmasq/default.conf . If I run QEMU using virt-manager, with ifconfig I can see that eth0 is configured with 192.168.122.115 . I can ssh to 192.168.122.115 from the host to guest with libvirt. I am not sure how to configure it without libvirt. Any help on this? (removing the second network did not help) @ChristianEhrhardt – Proy Jul 17 at 5:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.