Score:0

SSH to VM running on Virtual Box | kex_exchange_identification: read: Connection reset by peer

mx flag

Hi I'm running my VM on virtual box and trying to ssh to it from my MAC.

Setup:

Adapter 1:

  • NAT
  • Port Forwarding entry,
  • TCP
  • Protocol: TCP
  • Host IP: 127.0.0.1
  • Host Port: 2222
  • Guest Port:22

Adapter 2

  • Attached to: Host-only Adapter
  • Name: vboxnet0

After running: ssh [server]@127.0.0.1 -p 2222 -vv

I get the following error:

kex_exchange_identification: read: Connection reset by peer

terminal output: https://docs.google.com/document/d/1UXWG0zoJrPgJUi0E33NvX7diPdUgfKbh5Rt1DZk4w8w/edit?usp=sharing

Thanks for your help.

user535733 avatar
cn flag
There's a typo in your IP address. 127.0.01 is not a valid address.
Muhammed Özen avatar
in flag
Are you sure ssh server is running on vm? Check it by `systemctl status ssh`. You get a connection reset error which means target port turns out to be closed. If ssh is not running, try `sudo systemctl start ssh`
S224 avatar
mx flag
@user535733 thanks for the catch - I made a mistake while typing out the question but still have the same error
S224 avatar
mx flag
@MuhammedÖzen I tried the command - and the ssh server is running on the vm
in flag
If you’re SSHing into a VirtualBox instance, the IP should be something unique. 127.0.0.1 would point to your host, not the VM, meaning a machine is SSHing into itself
S224 avatar
mx flag
@matigo hmm, do you have any recommendations for how to get the correct VM address ? I mostly followed these tutorials, which ran ```ssh [change]@127.0.0.1 -p 5679```: - https://medium.com/nycdev/how-to-ssh-from-a-host-to-a-guest-vm-on-your-local-machine-6cb4c91acc2e - https://stackoverflow.com/questions/15580525/virtualbox-port-forwarding-not-working-with-nat-adapter
in flag
Generally I’ve found VirtualBox instances easier to work with on a network if they’re using Host-Only and/or Bridged adapters. It will also be important to ensure that the network adapter’s “promiscuous mode” is set to “Allow All”
Muhammed Özen avatar
in flag
can you give me your vm's local ip address that comes up when you type `ifconfig`?
S224 avatar
mx flag
@MuhammedÖzen https://docs.google.com/document/d/1zNMTwq7_hvO8xO1eXOq8ErJrOOUxNawRqQycRjk978k/edit?usp=sharing
Muhammed Özen avatar
in flag
If that's the only ip you get, you have no interface to talk to your host operating system. It's the loopback interface that basically send all the traffic back to your computer. You need to see something like eth0
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.