I have 3 Servers, A is a public accessable Server in the Internet.
B Hosts a Webservice I want to access.
C has access rights to connect to A and B.
Now i want that if a Client D tries to access a special Port on A that he gets forwarded to B.
IP's and Ports
A:
- 1.0.0.1:22 SSHD Server
- 1.0.0.1:443 Public Port which i want to use
B:
- 1.0.0.2:23 SSHD Server
- 1.0.0.2:444 Webservice I want to access
C:
- 1.0.0.3
D:
- 1.0.0.4
Diagram:
+------------+ +------------+
| Client (D) +--------> Public (A) |
+------------+ +-----^------+
|
+----------------+ +-----------+
| Webservice (B) <----+ Proxy (C) |
+----------------+ +-----------+
Question:
What ssh tunnel Commands do i need to execute on C so that if i try to open 1.0.0.1:443 on D i get the service hosted on 1.0.0.2:444 ?
Best Answer
On C you can run
It will only work if you login as
root
user because443
is a privileged port. Moreover it only works ifsshd
on A is configured withGatewayPorts
set toyes
orclientspecified
. (The default isno
and usingyes
cannot be recommended, so if you want to do it this way I recommendclientspecified
).