Port forward on VPS

Hello,
I want to Port forward on a VPS. I am a newbie and I never hosted a VPS. The reason i want to do that is cause I want to handle the connections of my metasploit users over VPS instead of opening a port on my router. I think its similar to port forward with NO-IP. but with your own service.

Hi @Maurice, you can look into port forwarding through ssh. You can forward many types of internet traffic through ssh. I suggest you start from this article https://help.ubuntu.com/community/SSH/OpenSSH/PortForwarding

1 Like

Thanks for the anwser. I still dont understand it right. I need to use remote port forward i think? How can i set my VPS to communicate with my kali so i can access my victims? Do i have to use this command ssh -R 5900:localhost:5900 and set localhost to my VPS IP? And when i create the backdoor i put the vps as ip and the port?

I have set ssh -R 5900:localhost:5900, fired up an HTTPServer on 80, set Gatewayports to yes, and use the ip of my server in the trojan and the listener i use my localhost as ip and both are the ports 5900. But i still dont receive any connections. Could you help me with that? I followed the instructions of 2 videos but somehow it doesnt work. I think i maybe have these ports closed on my VPS. (5900) is this a problem? 5900 is only a example of the port, i tried it with 1234, 5555, and other ports.

Try opening port 80 (either installing Apache or using HTTServer) on the VPS and then run ssh -L 5900:localhost:80 <server_name> and see if you can do localhost:5900 on your browser and access the server. I have my jupyter set up on my Ubuntu VPS and it is on port 8888. I use the command ssh -L 5900:localhost:8888 <server_name> and it works fine.

Í can access the VPS Localhost server now. I used 8000:localhost:80 <server_name> and set the HTTServer to 80. When i create a payload now, do i have to put the server name as lhost and lport 8000. listener is 127.0.0.1 and port 8000 too?

You should put the server’s public IP as the LHOST and the port you are getting it on as the LPORT. Once the server starts receiving the connection, you can forward it to your machine using the ssh command

I have put my servername as lhost and the 8000 as lport in my trojan. My listener is 127.0.0.1 and my lport 8000. When i do netstat -ntl on my VPS it shows port 127.0.0.1:8000 open and 0.0.0.0:80 open.
When i open my trojan with my windows machine and start the listener (windows/meterpreter/reverse_tcp) i still get no connection. I used the same methods in listener and payload.

i have tried it with -l local port as you said and with -r remote port. In the videos i watched it works easy but when i try it it doesnt work even if i follow it exactly. Even the same vps host. Im getting kinda frustrated.

When i try curl 127.0.0.1:8000 it says connect_to 127.0.0.1 port 80 failed at the third terminal the remote ssh layering cli

From the screenshot, I see that you are putting your loopback address for LHOST. You have to put your VPS public IP, I suppose. Can you share the video link that you are referring to?


Thats the video i am referring to.

Are you using DigitalOcean for your VPS and setting the private networking on? I don’t see any other thing that may be impacting your connection. Also, did you put the LHOSt as your server’s Public IP during exploit creation using msfvenom?

Yes i am using digitalocean and i put the lhost correctly, i do it with ngrok and it works fine. I dont know about the private networking, where can i find this setting? I only have Portmapping on yes

The private networking option must be in the digitalocean settings