5 make question clearer
source | link

How to create SSH reverse tunnel with iptables for forwarding?

I have a server in my home network (cannot port forward) and a VPS on the WAN. I need requests on a certain port, to, not from, the VPS to be forwarded to my home server. I have an SSH tunnel which works fine if iI send the request to localhost on the VPS, however. However I need a way to forwardwant requests to the VPSforwarded to VPS's localhost to send them through the tunnelfrom internet be sent to my home server through the tunnel. And it needs to be bi-directional.

I have seen this question, however it doesn't work for me. It is quite possible that I did something incorrectly.

EDIT:

My exact procedure:
On server a, my home server, I ran this command to set up the tunnel:
ssh -v -N -R 2222:localhost:22 root@server-b.com (server b is the VPS)

ssh -v -N -R 2222:localhost:22 root@server-b.com

I ran the following command on server b (VPS):
iptables -t nat -A PREROUTING -p tcp --dport 2223 -j DNAT --to-destination 127.0.0.1:2222

iptables -t nat -A PREROUTING -p tcp --dport 2223 -j DNAT --to-destination 127.0.0.1:2222

And tried to ssh from another machine:
ssh root@vps.com -p 2223

ssh root@server-b.com -p 2223

EDIT: I set GatewayPorts to yes in sshd_config however I am still finding the same problem - ssh: connect to host remotevps.com port 2223: Connection refused:
ssh: connect to host server-b.com port 2223: Connection refused.

SSH tunnel with iptables for forwarding

I have a server in my home network (cannot port forward) and a VPS on the WAN. I need requests on a certain port, to, not from, the VPS to be forwarded to my home server. I have an SSH tunnel which works fine if i send the request to localhost on the VPS, however I need a way to forward requests to the VPS to localhost to send them through the tunnel to my home server. And it needs to be bi-directional.

I have seen this question, however it doesn't work for me. It is quite possible that I did something incorrectly.

EDIT:

My exact procedure:
On server a, my home server, I ran this command to set up the tunnel:
ssh -v -N -R 2222:localhost:22 root@server-b.com (server b is the VPS)

I ran the following command on server b:
iptables -t nat -A PREROUTING -p tcp --dport 2223 -j DNAT --to-destination 127.0.0.1:2222

And tried to ssh from another machine:
ssh root@vps.com -p 2223

EDIT: I set GatewayPorts to yes in sshd_config however I am still finding the same problem - ssh: connect to host remotevps.com port 2223: Connection refused

How to create SSH reverse tunnel with iptables forwarding?

I have a server in my home network (cannot port forward) and a VPS on the WAN. I need requests on a certain port, to, not from, the VPS to be forwarded to my home server. I have an SSH tunnel which works fine if I send the request to localhost on VPS. However I want requests forwarded to VPS's localhost from internet be sent to my home server through the tunnel. And it needs to be bi-directional.

I have seen this question, however it doesn't work for me. It is quite possible that I did something incorrectly.

My exact procedure:
On server a, my home server, I ran this command to set up the tunnel:

ssh -v -N -R 2222:localhost:22 root@server-b.com

I ran the following command on server b (VPS):

iptables -t nat -A PREROUTING -p tcp --dport 2223 -j DNAT --to-destination 127.0.0.1:2222

And tried to ssh from another machine:

ssh root@server-b.com -p 2223

I set GatewayPorts yes in sshd_config however I am still finding the same problem:
ssh: connect to host server-b.com port 2223: Connection refused.

4 added 169 characters in body
source | link

I have a server in my home network (cannot port forward) and a VPS on the WAN. I need requests on a certain port, to, not from, the VPS to be forwarded to my home server. I have an SSH tunnel which works fine if i send the request to localhost on the VPS, however I need a way to forward requests to the VPS to localhost to send them through the tunnel to my home server. And it needs to be bi-directional.

I have seen this question, however it doesn't work for me. It is quite possible that I did something incorrectly.

EDIT:

My exact procedure:
On server a, my home server, I ran this command to set up the tunnel:
ssh -v -N -R 2222:localhost:22 root@server-b.com (server b is the VPS)

I ran the following command on server b:
iptables -t nat -A PREROUTING -p tcp --dport 2223 -j DNAT --to-destination 127.0.0.1:2222

And tried to ssh from another machine:
ssh root@vps.com -p 2223

EDIT: I set GatewayPorts to yes in sshd_config however I am still finding the same problem - ssh: connect to host remotevps.com port 2223: Connection refused

I have a server in my home network (cannot port forward) and a VPS on the WAN. I need requests on a certain port, to, not from, the VPS to be forwarded to my home server. I have an SSH tunnel which works fine if i send the request to localhost on the VPS, however I need a way to forward requests to the VPS to localhost to send them through the tunnel to my home server. And it needs to be bi-directional.

I have seen this question, however it doesn't work for me. It is quite possible that I did something incorrectly.

EDIT:

My exact procedure:
On server a, my home server, I ran this command to set up the tunnel:
ssh -v -N -R 2222:localhost:22 root@server-b.com (server b is the VPS)

I ran the following command on server b:
iptables -t nat -A PREROUTING -p tcp --dport 2223 -j DNAT --to-destination 127.0.0.1:2222

And tried to ssh from another machine:
ssh root@vps.com -p 2223

I have a server in my home network (cannot port forward) and a VPS on the WAN. I need requests on a certain port, to, not from, the VPS to be forwarded to my home server. I have an SSH tunnel which works fine if i send the request to localhost on the VPS, however I need a way to forward requests to the VPS to localhost to send them through the tunnel to my home server. And it needs to be bi-directional.

I have seen this question, however it doesn't work for me. It is quite possible that I did something incorrectly.

EDIT:

My exact procedure:
On server a, my home server, I ran this command to set up the tunnel:
ssh -v -N -R 2222:localhost:22 root@server-b.com (server b is the VPS)

I ran the following command on server b:
iptables -t nat -A PREROUTING -p tcp --dport 2223 -j DNAT --to-destination 127.0.0.1:2222

And tried to ssh from another machine:
ssh root@vps.com -p 2223

EDIT: I set GatewayPorts to yes in sshd_config however I am still finding the same problem - ssh: connect to host remotevps.com port 2223: Connection refused

3 added 406 characters in body
source | link

I have a server in my home network (cannot port forward) and a VPS on the WAN. I need requests on a certain port, to, not from, the VPS to be forwarded to my home server. I have an SSH tunnel which works fine if i send the request to localhost on the VPS, however I need a way to forward requests to the VPS to localhost to send them through the tunnel to my home server. And it needs to be bi-directional.

I have seen this question, however it doesn't work for me. It is quite possible that I did something incorrectly.

EDIT:

My exact procedure:
On server a, my home server, I ran this command to set up the tunnel:
ssh -v -N -R 2222:localhost:22 root@server-b.com (server b is the VPS)

I ran the following command on server b:
iptables -t nat -A PREROUTING -p tcp --dport 2223 -j DNAT --to-destination 127.0.0.1:2222

And tried to ssh from another machine:
ssh root@vps.com -p 2223

I have a server in my home network (cannot port forward) and a VPS on the WAN. I need requests on a certain port, to, not from, the VPS to be forwarded to my home server. I have an SSH tunnel which works fine if i send the request to localhost on the VPS, however I need a way to forward requests to the VPS to localhost to send them through the tunnel to my home server. And it needs to be bi-directional.

I have seen this question, however it doesn't work for me. It is quite possible that I did something incorrectly.

I have a server in my home network (cannot port forward) and a VPS on the WAN. I need requests on a certain port, to, not from, the VPS to be forwarded to my home server. I have an SSH tunnel which works fine if i send the request to localhost on the VPS, however I need a way to forward requests to the VPS to localhost to send them through the tunnel to my home server. And it needs to be bi-directional.

I have seen this question, however it doesn't work for me. It is quite possible that I did something incorrectly.

EDIT:

My exact procedure:
On server a, my home server, I ran this command to set up the tunnel:
ssh -v -N -R 2222:localhost:22 root@server-b.com (server b is the VPS)

I ran the following command on server b:
iptables -t nat -A PREROUTING -p tcp --dport 2223 -j DNAT --to-destination 127.0.0.1:2222

And tried to ssh from another machine:
ssh root@vps.com -p 2223

2 deleted 95 characters in body
source | link
1
source | link