1

I am trying to transfer file from a remote server behind jumphost server to my local machine using pscp and SFTP. I know how to do it for a remote server but not for jumphost-ed server. Also I need to make it automated (no user interaction needed), how do I do it? Thanks.

Martin Prikryl
  • 188,800
  • 56
  • 490
  • 992

2 Answers2

1

You can do it the same way you already execute command over the jump host:
Execute commands on remote server behind another server (jumphost) using Plink

Just use pscp, where you are using plink.

Something like this:

pscp -pw password2 -proxycmd "plink -ssh user1@jumphost -pw password1 -nc anotherIP:22" user2@example.com:/remote/path/file.txt .
Martin Prikryl
  • 188,800
  • 56
  • 490
  • 992
0

You can use a proxycommand:

scp -oProxyCommand = "ssh -W %h:%p username/password@jumphost" username/password@remotehost:/some/path/on/remote/host some/path/on/local/machine
Cyrille MODIANO
  • 2,246
  • 2
  • 21
  • 33
  • Where do I add the username,ip and password for server 1(the main server to connect to) and server 2(the next server where I jump to)? I can only see 1 %h %p combination (if it means hostip and password) – Mayank Sharma Jul 23 '21 at 13:03
  • I ran this command but it's showing missing argument. I ran `scp -oProxyCommand = "ssh -W %h:%p username1/pass1@ip1" username2/"pass2"@ip2:\path\to\file\inside\server\file.csv C:\Users\Mayank\Desktop ` I used "" in pass2 because the pass had @ in it, so I thought i'd escape that. it ran same as without the "" and both time threw error `The filename, directory name, or volume label syntax is incorrect.` But I have access to it in gui putty using the same path – Mayank Sharma Jul 23 '21 at 14:03
  • OpenSSH tools (`ssh`, `scp`, `sftp`) cannot accept password on their commands line. – Martin Prikryl Jul 24 '21 at 09:22