0

I have an Ubuntu 18 Guest on Virtual Box 6 running over windows 10. I need to ssh into the ubuntu machine. I've set a nat rule from my host 3022 port to port 22 on the guest. Configuration as follows: enter image description here

But whenever I try to ssh into the machine I'm getting the following error:

ssh -l vfbsilva localhost  -p 3022
ssh_exchange_identification: read: Connection aborted

I`m using the https://cmder.net/ terminal emulator, might this be the problem?

  • Just to check, adapter is of NAT type ? – Bharat May 7 at 17:26
0

Variables:

  • Host IP - 192.168.99.1
  • Guest IP - 192.168.99.2
  • NAT interface (#1) - enp0s3
  • Host-only interface (#2) - enp0s8
  • OpenSSH in both host and guest

Change the IP addresses as your setup.

Procedure:

  • Enable second network adapter as host only interface:
VBoxManage modifyvm "Ubuntu" --nic2 hostonly 
VBoxManage modifyvm "Ubuntu" --hostonlyadapter1 "VirtualBox Host-Only Network" 
  • Add static private IPv4 address in host only interface:
netsh interface ip set address "VirtualBox Host-Only Network" static 192.168.99.1 255.255.255.0 
  • Add static private IPv4 address in guest:

Add the IP address in Network Manager or Add these lines in /etc/network/interfaces file.

# NAT network interface
auto enp0s3
iface enp0s3 inet dhcp

# Host-Only network interface
auto enp0s8
iface enp0s8 inet static
    address 192.168.99.2
    netmask 255.255.255.0

Restart network interfaces with sudo ifdown -a; sudo ifup -a command.

  • Allow the IP addresses in firewall (if any). Try to ping each other.

  • Generate ssh key pair and copy the public one:

ssh-keygen -t rsa
ssh-copy-id user@192.168.99.2
  • Add port forwarding in NAT interface:
VBoxManage modifyvm "Ubuntu" --natpf1 "guestssh,tcp,127.0.0.1,3022,192.168.99.2,22"
  • Restart VM and SSH with ssh -p 3022 user@localhost.

Further reading

VirtualBox Manual: VboxManage

  • By some reason I cant figure out it did not work. – vfbsilva May 6 at 19:11
  • @vfbsilva Does host and guest ping each other? – Biswapriyo May 6 at 19:47
  • ssh_exchange_identification: read: Connection aborted. And they dont ping each other. I might have messed something up. How do I remove all created netowrks? – vfbsilva May 7 at 5:28
  • @vfbsilva It is not possible to discuss this in short Q&A session. You've to consult the VBox manual. – Biswapriyo May 7 at 5:38

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.