Linux QEMU - Guest can SSH to Host, but Host to Guest
阿新 • • 發佈:2020-11-04
Here is the command I use to boot 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
Once QEMU is booted, I try to SSH using the following command and get this 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 with this is 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 runningsshd
,
ps -ef | grep '[s]shd'
root 616 1 0 Dec11 ? 00:00:00 /usr/sbin/sshd -D
This is an excerpt of/var/log/auth.log
on the Guest if it helps. I'm reading an authentication failure, but unsure what that means as the timestamps don't align with when my host was 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)