Last active
February 10, 2025 22:19
-
-
Save AhsenBaig/0bceed5bff813c1bc3edb2f883734b2c to your computer and use it in GitHub Desktop.
WinSCP - Replace PuTTY with Windows Terminal
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 | |
@REM WinSCP PuTTY/Terminal client path: | |
@REM "<drive>:\<Path_to_file>\WindowsTerminal.bat" "!K" !U@!@ !# !/ "!N" | |
@REM setlocal | |
setlocal enabledelayedexpansion | |
SET "debugMode=n" | |
SET "Line=======================" | |
@set /a count = 1 | |
@REM SET pem extension from ppk file | |
SET "KeyExt=pem" | |
SET "KeyFile=%~1" | |
@REM SET KeyFile value | |
SET "KeyFile=!KeyFile:ppk=%KeyExt%!" | |
SET "SSH_PATH=cd %4 && exec bash -l" | |
@REM SSH Command for Terminal: | |
SET "SSH_CMD=ssh -i "%KeyFile%" -p %3 -t %2 \"!SSH_PATH!"\" | |
IF /I %debugMode% == y ( | |
ECHO !Line! | |
ECHO Debuging | |
ECHO !Line! | |
ECHO | |
ECHO !Line! | |
ECHO All prameters: %* | |
for %%x in (%*) do ( | |
echo Cnt: !count! Val: %%x | |
SET /a count+=1 | |
) | |
ECHO !Line! | |
ECHO GET KeyFile value: %1 | |
ECHO SET KeyFile value: "!KeyFile!" | |
ECHO !Line! | |
ECHO Example: | |
SET "EXAMPLE_PATH=cd <remote_path>/<sub_dir>/ && exec bash -l" | |
ECHO "ssh -i <key> -p <port> -t \"!EXAMPLE_PATH!"\"; | |
ECHO | |
ECHO !Line! | |
ECHO Parsed: | |
ECHO SSH_PATH: !SSH_PATH! | |
ECHO SSH_CMD: !SSH_CMD! | |
ECHO !Line! | |
PAUSE | |
) ELSE ( | |
ECHO Debug: off | |
) | |
@REM For Current Windows Terminal | |
@REM ECHO C:\Windows\System32\cmd.exe /c start /b %USERPROFILE%\AppData\Local\Microsoft\WindowsApps\wt.exe !SSH_CMD! | clip && notepad | |
C:\Windows\System32\cmd.exe /c start /b %USERPROFILE%\AppData\Local\Microsoft\WindowsApps\wt.exe !SSH_CMD! | |
ENDLOCAL |
I use:
wt.exe -w 0 ssh.exe -i !K.pem !U@!@ -p !# -t "cd !/ \; /bin/bash -l"
Openssh Key file is saved as [file].ppk.pem & [file].ppk is the PuttyKeyfile I use for Winscp.
This omits the use of above script.
Use this instead :
wt.exe cmd /k ssh !U@!@
and disable
Remember session password and pass it to PuTTY' (SSH)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
WinSCP released new docs that show other methods including WSL: https://winscp.net/eng/docs/integration_putty#wsl