Linux QEMU - guest can be hosted to host via SSH, but can be hosted to guest


Tex4066

I'm having some issues networking with the Host-Guest via SSH. I went through many questions here and QEMU's networking documentation ( https://wiki.qemu.org/Documentation/Networking#How_to_get_SSH_access_to_a_guest ) but couldn't find an answer.

My guest QEMU instance is able to SSH into the host as usual. However, when I try to SSH into the QEMU instance from the host, I get an ssh_exchange_identification: read: Connection reset by peererror.

Here is the command I use to start QEMU:

qemu-system-aarch64 -M virt -m 32768 -cpu cortex-a72 \
  -kernel $VMLINUZ \
  -initrd $INITRD \
  -append 'root=/dev/vda2' \
  -drive if=none,file=$COW,format=qcow2,id=hd \
  -device virtio-blk-pci,drive=hd \
  -netdev user,id=mynet \
  -device virtio-net-pci,netdev=mynet \
  -nographic \
  -device e1000,netdev=net0 \
  -netdev user,id=net0,hostfwd=tcp::5555-:22

After starting QEMU, I tried to SSH with the following command and got the following output:

<*user*>@<*hostname*>:~$ ssh localhost -p 5555 -vvv
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 5555
debug2: ssh_connect_direct: needpriv 0
debug1: Connecting to localhost [127.0.0.1] port 5555.
debug1: Connection established.
debug1: identity file /home/<*user*>/.ssh/id_rsa type 0
debug1: key_load_public: No such file or directory
debug1: identity file /home/<*user*>/.ssh/id_rsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/<*user*>/.ssh/id_dsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/<*user*>/.ssh/id_dsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/<*user*>/.ssh/id_ecdsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/<*user*>/.ssh/id_ecdsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/<*user*>/.ssh/id_ed25519 type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/<*user*>/.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

Any help would be greatly appreciated!

edit:

Both machines are running Ubuntu 18.04.

host:

Linux trace5 5.0.0-37-generic #40~18.04.1-Ubuntu SMP Thu Nov 14 12:06:39 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux

guest:

Linux qemu-trace 5.2.0-050200-generic #201907072331 SMP Sun Jul 7 23:48:00 UTC 2019 aarch64 aarch64 aarch64 GNU/Linux

guest is running sshd,

ps -ef | grep '[s]shd'
root 616 1 0 Dec11 ? 00:00:00 /usr/sbin/sshd -D

/var/log/auth.logHere 's an excerpt from the Guest if it helps . I'm reading Authentication failed, but not sure what that means because the host timestamp doesn't match it when ssh-ing:

Dec 11 18:43:17 qemu-trace sshd[1547]: Server listening on 0.0.0.0 port 22.
Dec 11 18:43:17 qemu-trace sshd[1547]: Server listening on :: port 22.
Dec 11 18:43:17 qemu-trace sudo: pam_unix(sudo:session): session closed for user root
Dec 11 18:45:30 qemu-trace systemd-logind[610]: New seat seat0.
Dec 11 18:45:33 qemu-trace sshd[617]: Server listening on 0.0.0.0 port 22.
Dec 11 18:45:33 qemu-trace sshd[617]: Server listening on :: port 22.
Dec 11 18:46:18 qemu-trace login[620]: pam_unix(login:session): session opened for user trace by LOGIN(uid=0)
Dec 11 18:46:19 qemu-trace systemd-logind[610]: New session 1 of user trace.
Dec 11 18:46:19 qemu-trace systemd: pam_unix(systemd-user:session): session opened for user trace by (uid=0)
Dec 11 19:17:01 qemu-trace CRON[675]: pam_unix(cron:session): session opened for user root by (uid=0)
Dec 11 19:17:02 qemu-trace CRON[675]: pam_unix(cron:session): session closed for user root
Dec 11 19:20:13 qemu-trace systemd-logind[605]: New seat seat0.
Dec 11 19:20:17 qemu-trace sshd[616]: Server listening on 0.0.0.0 port 22.
Dec 11 19:20:17 qemu-trace sshd[616]: Server listening on :: port 22.
Dec 11 19:22:33 qemu-trace login[621]: pam_unix(login:auth): check pass; user unknown
Dec 11 19:22:33 qemu-trace login[621]: pam_unix(login:auth): authentication failure; logname=LOGIN uid=0 euid=0 tty=/dev/ttyAMA0 ruser= rhost=
Dec 11 19:22:37 qemu-trace login[621]: FAILED LOGIN (1) on '/dev/ttyAMA0' FOR 'UNKNOWN', Authentication failure
Dec 11 19:22:49 qemu-trace login[621]: pam_unix(login:session): session opened for user trace by LOGIN(uid=0)
Dec 11 19:22:49 qemu-trace systemd-logind[605]: New session 1 of user trace.
Dec 11 19:22:50 qemu-trace systemd: pam_unix(systemd-user:session): session opened for user trace by (uid=0)
Tex4066

I found the problem; I have a problem with my QEMU command. New command to start QEMU:

qemu-system-aarch64 -M virt -m 32768 -cpu cortex-a72 \
  -kernel $VMLINUZ \
  -initrd $INITRD \
  -append 'root=/dev/vda2' \
  -drive if=none,file=$COW,format=qcow2,id=hd \
  -device virtio-blk-pci,drive=hd \
  -netdev user,id=mynet \
  -device virtio-net-pci,netdev=mynet,hostfwd=tcp::2222-:22 \
  -nographic

Then I can SSH from the host:

<user>@<host>:~$ ssh <host>@localhost -p 2222
<user>@localhost's password: 
Welcome to Ubuntu 18.04.2 LTS (GNU/Linux 5.2.0-050200-generic aarch64)

 * Documentation:  https://help.ubuntu.com
 * Management:     https://landscape.canonical.com
 * Support:        https://ubuntu.com/advantage

Last login: Thu Dec 12 14:31:28 2019
<user>@<guest>:~$

Related


The host cannot SSH the guest, but the guest can

Samaras This is a follow-up question from: Getting virtualbox to get a different IP address than my laptop . I ended up using these files /etc/hostson both my laptop (host) running Ubuntu 14.04 and my virtual machine (guest) running Ubuntu 14.04 : 127.0.0.1

The host cannot SSH the guest, but the guest can

Samaras This is a follow-up question from: Getting virtualbox to get a different IP address than my laptop . I ended up using these files /etc/hostson both my laptop (host) running Ubuntu 14.04 and my virtual machine (guest) running Ubuntu 14.04 : 127.0.0.1

QEMU - Ubuntu Guest on Ubuntu Host - install fine, can't reboot

ID hockey player I have successfully installed QEMU for VGA passthrough. I can invite a guest to read the Ubuntu ISO and it will find the img drive assigned to me fallocate -l 100G /VMs/VMs/video_gpu.img The installation seems to be fine. When I removed the -

QEMU - Ubuntu Guest on Ubuntu Host - install fine, can't reboot

ID hockey player I have successfully installed QEMU for VGA passthrough. I can invite a guest to read the Ubuntu ISO and it will find the img drive assigned to me fallocate -l 100G /VMs/VMs/video_gpu.img The installation seems to be fine. When I removed the -

How to SSH from host to guest using QEMU?

Jobin How to setup ssh from host to guest using qemu? When booting a virtual machine, you can use port redirection without any special parameters as follows: /usr/bin/qemu-system-x86_64 -hda ubuntu1204 -m 512 -redir tcp:7777::8001 However, when I try to boot

How to SSH from host to guest using QEMU?

Jobin How to setup ssh from host to guest using qemu? When booting a virtual machine, you can use port redirection without any special parameters as follows: /usr/bin/qemu-system-x86_64 -hda ubuntu1204 -m 512 -redir tcp:7777::8001 However, when I try to boot

Windows 10 host and Linux guest, can I swap the two licenses?

scarf I have Windows 10 64 bit pro. I did a free upgrade from the retail version of Windows 8.1 Pro. Now I have a Windows 10 host with a Linux guest. My system supports VT-x and VT-d for passing the graphics card from the host to the guest. I want to reverse t

Windows 10 host and Linux guest, can I swap the two licenses?

scarf I have Windows 10 64 bit pro. I did a free upgrade from the retail version of Windows 8.1 Pro. Now I have a Windows 10 host with a Linux guest. My system supports VT-x and VT-d for passing the graphics card from the host to the guest. I want to reverse t

Can I have a self-hosted VPN on a Linux host?

encephalopathy I have an account on a Linux host, is it possible to install a VPN (or opneVPN) on the server? Or do I need a special type of server? Camille It depends on your hosting company. If this is a small hosting company, you can ask them to configure a

Can I have a self-hosted VPN on a Linux host?

encephalopathy I have an account on a Linux host, is it possible to install a VPN (or opneVPN) on the server? Or do I need a special type of server? Camille It depends on your hosting company. If this is a small hosting company, you can ask them to configure a

Access internet host from qemu guest via bridged network

Robert Munteanu I am trying to setup multiple qemu tasks on the same private network. I want them not to be accessible outside the host, but they should be able to reach each other and get resources from the internet. For context, this will be an important kub

Access internet host from qemu guest via bridged network

Robert Munteanu I am trying to setup multiple qemu tasks on the same private network. I want them not to be accessible outside the host, but they should be able to reach each other and get resources from the internet. For context, this will be an important kub

Host-guest networking with qemu

byte fire I'm trying to get a host (arch linux) and a qemu guest (busybox initramfs linux) to connect to each other. No need for wider LAN access on the guest - just host-guest networking. The problem is that only the loopback interface is shown inside the qem

Host-guest networking with qemu

byte fire I'm trying to get a host (arch linux) and a qemu guest (busybox initramfs linux) to connect to each other. No need for wider LAN access on the guest - just host-guest networking. The problem is that only the loopback interface is shown inside the qem