WinSCP: tunnel through SSH to SFTP: save files on the intermediate machine (instead of local machine)

1

1

I use WinSCP from a local machine (machine A) to an SSH machine (machine B) which I use to tunnel through to machine C (to which I connect through SFTP). So far all good.

(create new session with the hostname and login/pass of machine C then do -> advanced settings -> connection: tunnel and put the hostname and login/pass of machine B in there.)

Now comes the rub.

I would like to copy files from machine C to machine B, without an intermediate copy to machine A (the files are too big and the connection between A and B too feeble).

I have of course tried opening both sessions (A<->B and B<->C) at once and copy-paste files from C to B but it seems an intermediate save on A is attempted: the box "Duplicate via local Temporary copy" in the "Duplicate" menu is checked in and I cannot uncheck it. The online help mentions

"When duplicating to different session, the only option is to duplicate via local temporary copy"

My question is: Is there a way to transfer files from C to B without intermediate copy to B?

Any ideas?

user189035

Posted 2019-12-25T08:00:19.613

Reputation: 113

Answers

1

The only way to get files from C to B directly is running a software (SFTP/SCP client) on either of these machines. WinSCP cannot do that for you.

It might be possible with command-line scp, which has server-to-server copy mode (it internally runs scp client on one of the servers over SSH connection). Though the tunneling part will complicate it. I didn't test it, but a setup like this may work:

scp C:file.txt localhost:file.txt -J B

Martin Prikryl

Posted 2019-12-25T08:00:19.613

Reputation: 13 764

I don't think that command will put the file on B, which is what he wants. As far as I can tell the only way to achieve that is to log in to B (no tunnel; straight ssh command line on B), then run "scp" or, better still, "sftp" there. – sitaram – 2019-12-26T01:15:13.340

@sitaram That's what the command should do. scp, when executed as scp host1:path1 host2:path2 internally connects to host1 and runs scp path1 host2:path2 there. – Martin Prikryl – 2019-12-26T08:28:42.033

as far as I can tell, that would require C (the host on the other side of the bastion host) to have a login on B (the bastion host). AIUI, only B->C is possible, not C->B. (And even then, this command did not work for me; though I may have flubbed something somewhere) – sitaram – 2019-12-26T09:34:00.627