Once you can reach the work server you can easily do that.
Assumption for the example
- source system (at home) : 10.0.0.1
- work system (jump server) : 10.0.0.2 (ssh is running on standard port 22/TCP)
- destination server : 10.0.0.3 (ssh is running on standard port 22/TCP)
- port forward via server B
With opening the ssh tunnel you can set local port forward (-L [<local_addr>:]<local_port>:<remote_addr_to_forward_to>:<remote_port_to_forward_to> ). Then you can open another ssh connection pointing <local_addr> but with parameter -p <local_port> or the first tunnel. With this configuration:
- the first tunnel have to be up to the rest is working
- you can have more connection over the first tunnel (more ssh connections, scp connection,...)
(1) ssh -L 10022:10.0.0.3:22 10.0.0.2
(2) ssh -p 10022 127.0.0.1
(3) scp -P 10022 <local_file> 127.0.0.1:<destination_file>
+-----+ +-----+ +-----+
| A |=== 1 ==| B | | C |
| | -- 2 - | -2- | - 2 -> | |
| | -- 3 - | -3- | - 3 -> | |
| |========| | | |
+-----+ +-----+ +-----+
10.0.0.1 10.0.0.2 10.0.0.3
- native ssh connection using "native" jump host
ssh offer "native" support for this kind of connection using -J <destination> parameter. For the specification of destination is recommended to use config (~./ssh/config) file.
The example of the code would be (the outer connection is "transparent")
(1) ssh -J 10.0.0.2 10.0.0.3
+-----+ +-----+ +-----+
| A |========| B | | C |
| | -- 1 - | -1- | - 1 -> | |
| |========| | | |
+-----+ +-----+ +-----+
10.0.0.1 10.0.0.2 10.0.0.3