Last active
March 23, 2025 14:20
-
-
Save Be1zebub/024acb15e16e2c7231ab484c97a717ce to your computer and use it in GitHub Desktop.
Run ssh sessions in winscp with openssh + windows terminal (ssh key auth only)
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 | |
REM 1. replace %ProgramFiles%\PuTTY\putty.exe in WinSCP settings (integrations > software > terminal path) | |
REM with "winscp_wt_ssh.bat !@ !# !U !/ !N" | |
REM 2. add your ssh key to ssh-agent (ssh-add %UserProfile%/.ssh/myShhKey) | |
REM if ssh-agent not running - use "Set-Service -Name ssh-agent -StartupType Automatic" & "Start-Service ssh-agent" | |
REM list of params that WinSCP sends to this batch script | |
REM wanna make sure its all good? add 6rd arg "debug" to this script launch params | |
REM 1. !@ - is hostname | |
REM 2. !# - is port | |
REM 3. !U - is username | |
REM 4. !/ - is path | |
REM 5. !N - is connection name | |
REM 6. debug - if the 6th parameter is "debug", print debug info | |
IF "%6"=="debug" ( | |
echo Debug mode activated. | |
echo All params: %* | |
echo 1. ^!@ ^(hostname^) - %1 | |
echo 2. ^!# ^(port^) - %2 | |
echo 3. ^!U ^(username^) - %3 | |
echo 4. ^!/ ^(path^) - %4 | |
echo 5. ^!N ^(connection name^) - %5 | |
PAUSE | |
exit /b | |
) | |
wt.exe new-tab --tabColor #003b33 --profile ssh-winscp --title %5 --suppressApplicationTitle ssh %3@%1 -p %2 -o ServerAliveInterval=60 -t "cd %4 \; bash --login" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment