Difference between revisions of "Tunneling with OpenSSH"
From Linuxintro
imported>ThorstenStaerk |
|||
(7 intermediate revisions by one other user not shown) | |||
Line 3: | Line 3: | ||
− | + | ----------------------------------------------------------- | |
− | + | | | | |
− | + | | | | |
− | + | --------- ----------- -------------- | | |
− | + | |localhost|-------------------------| gateway |------------------| hidden | | | |
− | + | --------- | 10.2.2.18 | | 172.16.0.42 | | | |
− | + | ----------- -------------- | | |
− | + | | | | |
− | + | ----------------------------------------------------------- | |
− | On localhost | + | On localhost forward port 2222 to hidden's port 22: |
ssh -L 2222:172.16.0.42:22 gateway | ssh -L 2222:172.16.0.42:22 gateway | ||
− | Then you can e.g. scp from localhost to ''hidden'' by using | + | Then you can e.g. scp from localhost to ''hidden'' by using localhost's port 2222: |
− | scp -P 2222 file1 | + | scp -P 2222 file1 localhost: |
+ | = Examples = | ||
+ | This command forwards your computer's port 8080 to port 8080 of the host "proxy": | ||
+ | ssh -gL 8080:proxy:8080 localhost | ||
= See also = | = See also = | ||
* [[set up NAT]] | * [[set up NAT]] |
Latest revision as of 12:19, 16 September 2015
SSH Tunneling or SSH port forwarding is typically useful if you have a network with a private segment like this:
----------------------------------------------------------- | | | | --------- ----------- -------------- | |localhost|-------------------------| gateway |------------------| hidden | | --------- | 10.2.2.18 | | 172.16.0.42 | | ----------- -------------- | | | -----------------------------------------------------------
On localhost forward port 2222 to hidden's port 22:
ssh -L 2222:172.16.0.42:22 gateway
Then you can e.g. scp from localhost to hidden by using localhost's port 2222:
scp -P 2222 file1 localhost:
Examples
This command forwards your computer's port 8080 to port 8080 of the host "proxy":
ssh -gL 8080:proxy:8080 localhost