diff --git a/README.md b/README.md index 1b7db8c..7113b2a 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,100 @@ -iface -===== +# iface +![](media/preview.jpg) +Rather bad Windows/Linux RPC interface specialized for a Windows-host/GNU+Linux-guest configuration. -Rather bad Windows/Linux RPC interface specialized for a Windows-host/Linux-guest configuration. +**WARNING**: The Windows/GNU+Linux iface by is EXPERIMENTAL and has nothing to do with good coding, security, etc. **USE AT YOUR OWN RISK**. -**WARNING**: The Windows/Linux iface by is EXPERIMENTAL and has nothing to do with good coding, security, etc. **USE AT YOUR OWN RISK**. +In this guide, I'll show you how to setup Windows-host + GNU/Linux-guest using a VMWare Workstation. -Some details on the configuration can be found here: -https://docs.google.com/document/d/1bq3lXdB2G4Mr2xVSxGdx6icleV7bfWbDUQUOuXzftTY/edit?usp=sharing +# Setting up a Virtual Network Interfaces +* Open VMWare Workstation +* Go to: Edit -> Virtual Network Editor +* Create one Bridged Network Interface and attach your physical Network Adapter to it (it will be used to get the internet access on your linux guest) +* Create another Host-Only Adapter with set it up like on picture below +![](media/virtual-adapters.jpg) + +# Virtual Machine Creation +Create a Virtual Machine as you always do, but attach two of those Network Interfaces to it and install your favourite GNU/Linux Distribution (Btw. I use Arch). + + +# VMWare Tools installation +* Arch Linux: ```sudo pacman -S open-vm-tools xf86-video-vmware``` +* Debian/Ubuntu-based: ```sudo apt install open-vm-tools xserver-xorg-video-vmware``` +* openSUSE: [software.opensuse.org](https://software.opensuse.org/download.html?project=Virtualization%3AVMware&package=open-vm-tools) + +# Clone this repo to your VM +``` +git clone https://github.com/synnek1337/win-linux-setup.git +``` +# Attaching host physical drivers to Virtual Machine +Make sure your on 4.x kernel or newer: ```uname -r```\ +Shut down the Virtual Machine. +In VMWare Workstation go to: **Edit this Virutal Machine settings** -> **Options** -> **Shared Folders** -> Check **Always enabled** -> **Add** -> Add the root folder of every partition you want to attach and name it **DRIVE_C**, **DRIVE_D** etc. + +![](media/disk_attaching.jpg) +![](media/disks_attached.jpg) + +Start the VM, go to ```win-linux-setup/guest-side-conf-scripts``` and do ```sudo python fstab-conf.py``` **!! USE PYTHON 3** + +# Set up Network Interfaces on your Guest +```nmtui``` +Set up your host-only interface ipv4 address to 192.168.56.3/24 + +# Set up Network Interface on your Host +**Control Panel** -> **Network and Sharing Center** -> **Change adapter settings** -> right-click on ***your host-only interface*** -> **Properties** -> **Internet Protocol Version 4 (TCP/IPv4)** -> set it like on picture belown + +![](media/network_configuration.jpg) + +# Set Up SSH Server on guest-side **(for easier troubleshoting)** +* Install OpenSSH and enable it like it' s described on your distro' s wiki (*https://wiki.archlinux.org/index.php/Secure_Shell*) +* edit ```/etc/ssh/sshd_config``` \ +in line ***13*** change ```port``` to something different that 22 **(eg. 2137)** \ +in line ***15*** change ```ListenAddress``` to **192.168.56.3** \ +in line ***57*** change ```PasswordAuthentication``` to **no** \ +in line ***32*** change ```PermitRootLogin``` to **no**. + +* Generate SSH Keys \ +```ssh-keygen``` and enter the passphrase \ +go to ```~/.ssh/``` and rename **id_rsa.pub** to **authorized_keys** \ +Transfer ```id_rsa``` to your host by ```cp id_rsa /c/...``` + +# Set Up PuTTY on Host-side +* [Download](https://the.earth.li/~sgtatham/putty/latest/w64/putty-64bit-0.70-installer.msi) PuTTY or ```choco install putty``` +* Open ```puttygen``` \ +**Conversions** -> **Import Key** -> **Save private key** +* Edit ```.\host-side-scripts\startup.bat``` \ +in line ***4*** ***enter path to your .ppk file***. +* Now you can easily connect to your VM +# Install VcXsrv +* [Download](https://sourceforge.net/projects/vcxsrv/) +* ```choco install vcsrv``` + +# Configure all host-side scripts +* go to ```.\host-side-scripts``` \ +In line *3* in ```l-cmd.bat``` enter path to this repo cloned. \ +In line *4* in ```startup.bat``` enter PATH to your private key in **.ppk** format. \ +In line *5* in ```startup.bat``` enter path to this repo cloned. \ +In line *3* in ```vm-start.bat``` and ```vm-stop.bat``` add path to **.vmx** file of your VM. + +* In ```shell:startup``` create link to ```repo\host-side-scripts\startup.bat``` + +# Configure iface +* Edit ```./RPC/iface.cfg``` \ +in line ***2*** enter secure password \ +in line ***3*** enter path to *home* directory on guest-side \ +in line ***6*** enter path to your **terminal emulator** \ +Use same iface.cfg both on guest and host side. + +# Add iface to autostart on guest-side +* correct ```guest-side-scripts\startup.sh``` +* Install **cron** *check your distro 's wiki* *(for arch it' s ```pacman -S cronie```)* +* ```crontab -e``` \ +```@reboot *PATH to startup.sh*``` \ +***ctrl+o*** ***ctrl+x*** + +# Credits +* [@gynvael](https://github.com/gynvael) for providing RPC Interface +* [@vmware](https://github.com/vmware) for providing virtualization solutions +* [@python](https://github.com/python) for providing Python Programming language \ No newline at end of file diff --git a/if-info.py b/RPC/if-info.py similarity index 100% rename from if-info.py rename to RPC/if-info.py diff --git a/if-l-cmd.py b/RPC/if-l-cmd.py similarity index 100% rename from if-l-cmd.py rename to RPC/if-l-cmd.py diff --git a/if-openurl.py b/RPC/if-openurl.py similarity index 100% rename from if-openurl.py rename to RPC/if-openurl.py diff --git a/if-stop.py b/RPC/if-stop.py similarity index 100% rename from if-stop.py rename to RPC/if-stop.py diff --git a/if-testpath.py b/RPC/if-testpath.py similarity index 100% rename from if-testpath.py rename to RPC/if-testpath.py diff --git a/iface.cfg b/RPC/iface.cfg similarity index 100% rename from iface.cfg rename to RPC/iface.cfg diff --git a/iface.py b/RPC/iface.py similarity index 100% rename from iface.py rename to RPC/iface.py diff --git a/ifaceclientlib.py b/RPC/ifaceclientlib.py similarity index 100% rename from ifaceclientlib.py rename to RPC/ifaceclientlib.py diff --git a/ifaceconfiglib.py b/RPC/ifaceconfiglib.py similarity index 100% rename from ifaceconfiglib.py rename to RPC/ifaceconfiglib.py diff --git a/guest-side-scripts/fstab-conf.py b/guest-side-scripts/fstab-conf.py new file mode 100644 index 0000000..e7eface --- /dev/null +++ b/guest-side-scripts/fstab-conf.py @@ -0,0 +1,14 @@ +#!/bin/env python + +from subprocess import check_output +from os import system + +drives = check_output("vmware-hgfsclient", shell=True).decode('utf-8').split() +fstab = open('/etc/fstab', 'a') + +for drive in drives: + fstab.write( + ".host:{} /mnt/{} fuse.vmhgfs-fuse rw,allow_other 0 0".format(drive, drive[0].lower())) + print("{} attached.".format(drive[0].lower())) + system("ln /mnt/{} /{}".format(drive[0].lower(), drive[0].lower())) + print("/{} link created.".format(drive[0].lower())) \ No newline at end of file diff --git a/guest-side-scripts/startup.sh b/guest-side-scripts/startup.sh new file mode 100644 index 0000000..4f6e0bf --- /dev/null +++ b/guest-side-scripts/startup.sh @@ -0,0 +1,20 @@ +#!/bin/bash +SCRIPT=/home/gynvael/iface/iface.py # Correct this. +SCRIPT_ARGS=--linux +PYTHON=/usr/local/bin/python # Make sure it' s path to python 2.7!!! +SLEEP=/bin/sleep + +# Retry 10 times. +for i in {0..10} +do + + if [ -e "$SCRIPT" ] + then + export SHELL=/bin/bash + $PYTHON $SCRIPT $SCRIPT_ARGS >/dev/null 2>/dev/null & + exit 0 + else + $SLEEP 2 + fi + +done diff --git a/host-side-scripts/l-cmd.bat b/host-side-scripts/l-cmd.bat new file mode 100644 index 0000000..7ba5940 --- /dev/null +++ b/host-side-scripts/l-cmd.bat @@ -0,0 +1,5 @@ +@echo off + +set %repopath%="Enter path to win-linux-setup directory" + +C:\python27\python.exe %repopath%\RPC\if-l-cmd.py %cd% \ No newline at end of file diff --git a/host-side-scripts/startup.bat b/host-side-scripts/startup.bat new file mode 100644 index 0000000..92dd135 --- /dev/null +++ b/host-side-scripts/startup.bat @@ -0,0 +1,20 @@ +@echo off +color a + +set %PRVKEY%="Enter path here" +set %repopath%="Enter path to win-linux-setup directory" + +echo Starting vcxsrv... +start c:\bin\vcxsrv.exe :0 -clipboard -multiwindows +start c:\bin\xhost.exe +192.168.56.3 +set DISPLAY=127.0.0.1:0 +echo vcxsrv is running. + +echo starting pageant... +start pageant %PRVKEY% + +echo starting virtual machine +call vm-start.bat + +echo starting Windows/Linux iface... +start c:\python27\python.exe %repopath%\RPC\iface.py --windows \ No newline at end of file diff --git a/host-side-scripts/vm-start.bat b/host-side-scripts/vm-start.bat new file mode 100644 index 0000000..b02aa7b --- /dev/null +++ b/host-side-scripts/vm-start.bat @@ -0,0 +1,6 @@ +@echo off + +set %VMPATH%="Enter path to .vmx file here" + +"C:\Program Files (x86)\VMware\VMware Workstation\vmrun.exe" start %VMPATH% nogui +echo "VM started." \ No newline at end of file diff --git a/host-side-scripts/vm-stop.bat b/host-side-scripts/vm-stop.bat new file mode 100644 index 0000000..d0c49db --- /dev/null +++ b/host-side-scripts/vm-stop.bat @@ -0,0 +1,6 @@ +@echo off + +set %VMPATH%="Enter path to .vmx file here" + +"C:\Program Files (x86)\VMware\VMware Workstation\vmrun.exe" stop %VMPATH% +echo "VM Stopped." \ No newline at end of file diff --git a/media/disk_attaching.jpg b/media/disk_attaching.jpg new file mode 100644 index 0000000..4999b19 Binary files /dev/null and b/media/disk_attaching.jpg differ diff --git a/media/disks_attached.jpg b/media/disks_attached.jpg new file mode 100644 index 0000000..cfe1df4 Binary files /dev/null and b/media/disks_attached.jpg differ diff --git a/media/network_configuration.jpg b/media/network_configuration.jpg new file mode 100644 index 0000000..e9dbde3 Binary files /dev/null and b/media/network_configuration.jpg differ diff --git a/media/preview.jpg b/media/preview.jpg new file mode 100644 index 0000000..482efbc Binary files /dev/null and b/media/preview.jpg differ diff --git a/media/virtual-adapters.jpg b/media/virtual-adapters.jpg new file mode 100644 index 0000000..c3e3341 Binary files /dev/null and b/media/virtual-adapters.jpg differ