Skip to content

Hyper V Device

tatiane edited this page Mar 16, 2021 · 6 revisions

This page shows how to set up a Hyper-V VM to simulated an IoT device that can be connected to the MBP installed in the host computer.

Requirements:

  • MBP installed and running on Windows 10 (Host OS)
  • Hyper-V installed and enabled in the Host OS
  • Guest image OS: Ubuntu 20.04 (download ISO file)

Steps

  1. Activate Hyper-V Windows feature and restart your PC

Go to "Systemsteuerung\Programme\Programme und Features"

  1. Start Hyper-V-Manager as administrator

  2. Create a Hyper-V virtual switch

Go to "Virtual Switch Manager..."

Set properties as above

  1. Set static IP address of newly created switch

Go to "Systemsteuerung\Netzwerk und Internet\Netzwerkverbindungen"

  1. In Hyper-V-Manager, create a VM and indicate the created switch and downloaded .iso image
  1. Start up the VM and install the OS

  2. Configure VM static IP address and restart the VM

  1. Test if connection works by pinging the VM from the host machine

ping 192.168.10.60 -n 3

  1. Install openssh-server in the VM
sudo apt-get update
sudo apt install openssh-server
  1. Enable key login in the VM
  • Edit file /etc/ssh/sshd_config

  • Add public key to /.ssh/authorized_keys

  • Make sure the VM normal user is the owner of this file

ls -la

  • Change owner if necessary

sudo chown mbp authorized_keys

  1. Test ssh connection from host machine

ssh -i .\hyperv-vm [email protected] -v

  1. If the connection don't work and the guest machine log in /var/log/auth.log shows the message no matching key exchange method found:
  • Add at the end of file /etc/ssh/sshd_config:
#Legacy changes  
KexAlgorithms +diffie-hellman-group1-sha1
  1. In the MBP, configure remote broker with IP address configured in step 4.
Screenshot 2020-11-09 at 17 55 05
  1. In the MBP, add device using the hyper-v VM IP address
  1. Create a sensor and connect it to this device. If installation of the operator is successful but starting is not, probably the windows firewall is blocking the port 1883. You can desactive the windows firewall or add to the windows firewall the mosquitto.exe as allowed application.

Helpful Links