Motivation: to ssh to the VM without always figuring out what the VM's current IP is.
Windows' default switch dynamically assigns IP address to Hyper V Vms whenever Windows restarts.
To assign a static IP address to a VM, we need to set up an Internal Switch.
Steps:
-
In Hyper V: Create an internal Switch
-
In
Control Panel\Network and Internet\Network Connections
Configure its IPv4 properties as follows:
IP address: 192.168.0.2
Subnet mask: 255.255.255.0
Default gateway: 192.168.0.1 // router -
Add the Switches to the VM. Your VM should have two network adapters: one Default and one Internal
-
Log into the VM, configure Networking as follows:
IPv4->Manual
Address: 192.168.0.3
Netmask: 255.255.255.0
Gateway: 192.168.0.1
Now you should be able to ping to your VM on Windows with static IP 192.168.0.3
- In Hyper-V, add the Internal Switch to the VM
- In the VM, configure the switch as follows:
IPv4->Manual
Address: 192.168.0.4
Netmask: 255.255.255.0
Gateway: 192.168.0.1
- On Linux guest: Set up samba server https://docs.fedoraproject.org/en-US/quick-docs/samba/
- On Windows host: Add a network location following this guide
https://www.tenforums.com/virtualization/174394-how-add-webcam-windows-10-vm-hyper-v.html
- Failed on Fedora 35
It fixes some weird issues (like cannot send Ctrl-<space>
via ssh).
- uninstall the current one from
Settings -> Optional features
- Install the latest version and update
PATH
following https://github.com/PowerShell/Win32-OpenSSH/wiki/Install-Win32-OpenSSH
- Open PowerShell Administrator
- Run
Set-VM -VMName 'Your VM Name' -EnhancedSessionTransportType HvSocket
- Install Xserver client [VcXSrv](https://sourceforge.net/projects/vcxsrv/
- Add to windows env variable: Name:
DISPLAY
, Value:localhost:0
- SSH to Linux with
-Y
:ssh -Y user@host
- Verify by checking if
xcalc
works - Set VIM to yank to system clipboard