How write a Windows batch file to be run from HostA for those connections below?
SSH (with local port forwarding): HostA => HostB => HostC.
HostA – HostB must use plink.exe
(HostA runs Windows)
HostB – HostC must use ssh
(HostB runs Linux).
I try this:
@echo off
chdir /d "C:\"
start plink.exe user_at_B@192.168.IP_of_B -pw userBpasswd
ssh -L user_at_C@192.168.IP_of_C
This batch script does not execute a second ssh
command (from B to C), it just opens a new CMD window in which nothing happens.
Please disregard password storage in a batch file for plink
.
You have to tell plink
to execute the ssh
, by passing the ssh
command to plink
commandline:
start plink.exe -t user_at_B@192.168.IP_of_B -pw userBpasswd ssh -L user_at_C@192.168.IP_of_C
When the command is provided on Plink command-line, Plink by default does not use a terminal emulation. To force the terminal emulation, the -t
switch needs to be added (as shown above).
Though:
ssh
command is wrong – With -L
you need to specify an additional argument.ssh
on the intermediate server.