3

I need to connect to a particular API but that API only accept request from my mate server. Then include thoses informations back in our website.

So basically I need to connect to the server make the request receiving the answer transfering it to my host so that I can play around with them and integrating them to my website through a php file.

I've already exchange ssh keys and I can connect to my server easily, I know I probably need to use ssh -L (not -R or -D) for the tunneling, though I don't know what to do with my php files to make that request etc etc or what are the other steps once I've entered that command.

If anyone can help that would be lovely :) !

1 Answers1

4

You can create an SSH tunnel using the -L command line switch:

$ ssh -L [port on local]:[apiserver hostname]:[port on apiserver] [user]@[your friend's server hostname]

E.g.

$ ssh -L 8080:apiserver.com:80 bob@friend.server.com

After the above command successfully connects to friend.server.com, any requests sent to your localhost:8080 will be tunneled through friend.server.com host and arrive at apiserver.com:80. From apiserver's perspective, the request's origin is friend's server.

(This will actually open an SSH session in the terminal window where executed, i.e. you get the prompt of the remote server, which is not required and you can ignore that prompt. It is possible ro run this in the background w/o console login with other switches)

marekful
  • 14,986
  • 6
  • 37
  • 59
  • 1
    Thanks a lot for the answer mate ! I actually did the trick with a basic ssh -D letting the terminal run on the background but you answer is much more complete and detailed so cheers once again – Coding_Maeda Sep 26 '21 at 06:05