Created
June 7, 2024 08:18
-
-
Save glebov21/5b44293a199a6ef8846b312744eb1795 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@echo off | |
set _HOST=ct100 | |
::^^^ Sets value for ssh target (host), please use Windows SSH config file, if you don't you must either set the key path with -i argument, or enter password manually when prompted by the console. | |
::^^^ Example value using key: | |
::^^^ _HOST="-i \Path\To\mykey user@ip". | |
set _USER=root@pam | |
::^^^ Sets the Proxmox user and authentication method, default is root@pam. | |
set _PASSWD=6969 | |
::^^^ Sets the password used for aforementioned auth method. | |
set _VMID=101 | |
::^^^ Sets the ID of the VM to connect to. | |
set _NODENAME=Proxmox | |
::^^^ Sets the node that the target VM resides on. | |
set _TARGETPROXY=192.168.4.420 | |
::^^^ Sets the IP that the remote script will query, which will also be the IP that the SPICE file points to. | |
:: Nothing below this line needs to be edited. | |
mkdir %AppData%\con2spice | |
rm %AppData%\con2spice\spiceproxy.vv | |
ssh "%_HOST%" bash /etc/spice/all.sh -u %_USER% -p %_PASSWD% %_VMID% %_NODENAME% %_TARGETPROXY% | |
scp "%_HOST%":/etc/spice/tmp/spiceproxy.vv %AppData%\con2spice\spiceproxy.vv | |
start "" "%ProgramData%\Microsoft\Windows\Start Menu\Programs\VirtViewer\Remote viewer.lnk" "%AppData%\con2spice\spiceproxy.vv" | |
::^^^ If you want, you can remove the quotes wrapping the last argument and the start "" portion of this command to launch Remote Viewer tied to the console window. | |
:: The only setup required for this script is to | |
:: A) Download and install OpenSSH for Windows, please keep in mind that only the client is needed. More information available here 'https://docs.microsoft.com/en-us/windows-server/administration/openssh/openssh_install_firstuse'. | |
:: B) Download and install Virt Viewer for Windows, which is available here 'https://virt-manager.org/download/sources/virt-viewer/virt-viewer-9.0.tar.gz' or here 'https://virt-manager.org/download/' for latest download. | |
:: C) Make a file named "all.sh" in a folder named "/etc/spice" with the correct content, and also create a subdirectory of spice named "tmp". | |
:: | |
:: C can be done with the following command on the remote: | |
:: 'mkdir -p /etc/spice/tmp && curl -o /etc/spice/all.sh https://pastebin.com/raw/gfwwaH1v %% chmod +x /etc/spice/all.sh'. | |
:: The above command makes the required directories and puts the BASH script in place. If you want to check out the original script, it is available here 'https://git.proxmox.com/?p=pve-manager.git;a=blob_plain;f=spice-example-sh;hb=HEAD'. | |
:: | |
:: For more information on Windows SSH config files, look here 'https://www.cloudsavvyit.com/4274/how-to-manage-an-ssh-config-file-in-windows-linux/'. | |
:: | |
:: If you wish to change the settings specified in the spiceproxy.vv file, please do so by adding using sed or another tool at the bottom of all.sh | |
:: | |
:: And most importantly, have a good day! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment