I would like to connect to a service running on port X on a host. The service cannot be reached on the host IP address and port. There are 2 options I know which can achieve this:
- Local port forwarding through SSH tunnelling. (ssh -L)
- Using 'SSH + socat'
Which of these is a preferred method? Any issues wrt security in the above methods, like is one of them considered more secure?
EDIT 1
- The services involved are TCP based.
- X is in the range of 2000-9999.
- The host machine (which has service running on port X) is only single user right now, which is root. But in future, it may have 2 users, one root and other non-root.
- This is the layout of the system:
People on internet call APIs to my service, say A. For A to serve the requests, it needs to contact the service on host which is running at port X. Direct access to host (including SSH) is only available to my service A.