Last active
November 10, 2023 05:13
-
-
Save igrep/6f40888aab6268c1d4b4c89a27122627 to your computer and use it in GitHub Desktop.
Abuse unison's -sshcmd option to synchronize with the VM on WSL without sshd.
This file contains 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
> unison C:\unison-test ssh://user@localhost/unison-test -retry 0 -repeat watch -sshcmd C:\\double\\backslashes\\path\\to\\wsl-as-ssh.cmd |
This file contains 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 "USER_NAME=" | |
rem ESCAPE_CHAR perhaps isn't helpful for WSL | |
rem set "ESCAPE_CHAR=" | |
rem PORT perhaps isn't helpful for WSL | |
rem set "PORT=" | |
set "HOST_NAME=" | |
set "COMMAND=" | |
:PARSE_ARGS | |
if "%~1"=="" goto :END_PARSE_ARGS | |
if "%~1"=="-l" ( | |
set "USER_NAME=%~2" | |
shift | |
) else if "%~1"=="-p" ( | |
rem set "PORT=%~2" | |
shift | |
) else if "%~1"=="-e" ( | |
rem set "ESCAPE_CHAR=%~2" | |
shift | |
) else ( | |
if not defined HOST_NAME ( | |
set "HOST_NAME=%~1" | |
) else ( | |
set "COMMAND=%COMMAND% %~1" | |
) | |
) | |
shift | |
goto :PARSE_ARGS | |
:END_PARSE_ARGS | |
wsl --cd "~" -u %USER_NAME% -- %COMMAND% |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
NOTE: Most of the wsl-as-ssh.cmd is written by ChatGPT (GPT 3.5).