Created
July 21, 2023 13:47
-
-
Save eru123/df609c9a4572a9427569409bee77fbea to your computer and use it in GitHub Desktop.
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 | |
setlocal EnableDelayedExpansion | |
set ports=%* | |
if "%ports%"=="" ( | |
echo Usage: %0 <Local Port 1>:<Server Port 1> [<Local Port 2>:<Server Port 2> ...] | |
exit /b 1 | |
) | |
@rem ssh account | |
set identityfile=%USERPROFILE%\.ssh\id_rsa | |
set sshusername=root | |
set sshhost= | |
set sshport= | |
set password= | |
set sshcmd=ssh -i "%identityfile%" -p %sshport% %sshusername%@%sshhost% -N | |
@rem tunnel ports, append to sshcmd | |
for %%p in (%ports%) do ( | |
for /f "tokens=1,2 delims=:" %%a in ("%%p") do ( | |
set serverport=%%a | |
set localport=%%b | |
set sshcmd=!sshcmd! -L !localport!:localhost:!serverport! | |
) | |
) | |
echo %sshcmd% | |
call %sshcmd% |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment