I'm doing something like this :
Code: Select all
ssh -l user -L 9999:remote-ip:8888 gateway-ip scp -P9999 remote-user@localhost:/remote-dir/* /local-dest/dir
Code: Select all
ssh: connect to host localhost port 9999: Connection refused
My interpretation is that when I call 'ssh ... scp ...' the tunnel closes imediatly after it is created and that is why following 'scp' command gives an error that it cannot connect to this port at the localhost.
The problem is that I want to do this in a script, which means it will be a headache 'cause I have to fork a process to open up the tunnel and then run the scp command and after that I have to kill this forked process...
So my question is there is an easier way to preserve the tunnel at least untul the scp command finish ??
thank you very much ...

