rivosinc / salus

Risc-V hypervisor for TEE development
96 stars 25 forks source link

Cannot connect to Debian via SSH while virtio-net-pci device enabled #318

Closed GDHNES closed 1 year ago

GDHNES commented 1 year ago

I was trying to SSH in Debian, then I got a kex_exchange_identification: read: Connection reset by peer like this:

gdhnes@gdhnes-Zephyrus-M15-GU502LV-GU502LV:~$ ssh localhost -p 7722 -l root -v
OpenSSH_8.2p1 Ubuntu-4ubuntu0.5, OpenSSL 1.1.1f  31 Mar 2020
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: include /etc/ssh/ssh_config.d/*.conf matched no files
debug1: /etc/ssh/ssh_config line 21: Applying options for *
debug1: Connecting to localhost [127.0.0.1] port 7722.
debug1: Connection established.
debug1: identity file /home/gdhnes/.ssh/id_rsa type 0
debug1: identity file /home/gdhnes/.ssh/id_rsa-cert type -1
debug1: identity file /home/gdhnes/.ssh/id_dsa type -1
debug1: identity file /home/gdhnes/.ssh/id_dsa-cert type -1
debug1: identity file /home/gdhnes/.ssh/id_ecdsa type -1
debug1: identity file /home/gdhnes/.ssh/id_ecdsa-cert type -1
debug1: identity file /home/gdhnes/.ssh/id_ecdsa_sk type -1
debug1: identity file /home/gdhnes/.ssh/id_ecdsa_sk-cert type -1
debug1: identity file /home/gdhnes/.ssh/id_ed25519 type -1
debug1: identity file /home/gdhnes/.ssh/id_ed25519-cert type -1
debug1: identity file /home/gdhnes/.ssh/id_ed25519_sk type -1
debug1: identity file /home/gdhnes/.ssh/id_ed25519_sk-cert type -1
debug1: identity file /home/gdhnes/.ssh/id_xmss type -1
debug1: identity file /home/gdhnes/.ssh/id_xmss-cert type -1
debug1: Local version string SSH-2.0-OpenSSH_8.2p1 Ubuntu-4ubuntu0.5
kex_exchange_identification: read: Connection reset by peer

I slightly modified the command by adding 2 additional lines

-monitor tcp:127.0.0.1:2277,server,nowait \
-device virtio-net-pci,iommu_platform=on,disable-legacy=on \

in run_debian.sh for convenience.

The solutions I found in StackOverflow posts didn't solve the problem. When -device virtio-net-pci,iommu_platform=on,disable-legacy=on is deleted, everything works well, is there any mistake I make? I am trying to do some experiments on the iommu parts, if virtio-net-pci just simply cannot work with SSH for some reason, is there any other possible virtio-pci device I can try?

abrestic-rivos commented 1 year ago

Instead of adding another net device, have you tried replacing the net device that's already instantiated here with virtio-net-pci?

GDHNES commented 1 year ago

No, I haven't try that until you suggest this method. It works after I replace the line

NETWORK_ARGS="-netdev user,id=usernet,hostfwd=tcp:127.0.0.1:7722-0.0.0.0:22 -device e1000e,netdev=usernet"

in script/common_variables with:

NETWORK_ARGS="-netdev user,id=usernet,hostfwd=tcp:127.0.0.1:7722-0.0.0.0:22 -device virtio-net-pci,iommu_platform=on,disable-legacy=on,netdev=usernet".

Thank you for your kind reply, that indeed save the day. :-)