Winscp Command line invocation using a jump host

I do a lot using a bastion host. Winscp provides for that. When you create a new host you can click on the command Advanced button, Connection Tunnel and tick the “Connect through SSH tunnel” box. You will have to fill in the host and user name. You can store the password but it's better/easier to rely on pageant for that (it's an key agent that is part of putty).

However, I don't want to do this for every host I may work with.

Thankfully we can run winscp from the command line. winscp user@host will allow us to start a session much like sftp user@host would.

But how about the jump host? That's pretty simple too, we just have to add a few more options. Namely, /rawsettings Tunnel=1 TunnelHostName=bastion TunnelUserName=username. That has to come after the user@host portion of the command.

I've wrapped this up in a bash script since I mostly work out of a cygwin terminal session but you could do something similar with a bat script.

wscph
#!/bin/bash 
 
PATH=$PATH:"/cygdrive/c/Program Files (x86)/WinSCP"
jumphost="/rawsettings Tunnel=1 TunnelHostName=bastion TunnelUserName=username"
 
cmd="winscp $@ $jumphost"
echo $cmd
exec $cmd &