Remotely access an elasticsearch server using SSH tunnel

Hi,

I have an elasticsearch node on a private network. This node is accessible through aws bastion. So I am trying to connect my local machine to the elasticsearch node by creating an SSH tunnel on port 9200. I use the following command to create the tunnel:

ssh -i <identity_file> user@<bastion_machine_ip> -L 9200:<remote_server's_private_ip>:9200 -N -v

When I try to curl to my localhost 9200 port curl http://localhost:9200, I get the following error:

curl: (56) Recv failure: Connection reset by peer

My elasticsearch.yml file contains the following:

network.host: 0.0.0.0
http.host: 0.0.0.0
http.port: 9200

Note: inbound rules on the remote server are set on port 9200

I tried commenting the http.host line from my elasticsearch.yml file but this makes the curl command to time out.

What am I doing wrong here?

Thanks!!!

I believe your problem is how you are defining your ssh tunnel.

local: -L Specifies that the given port on the local (client) host is to be forwarded to the given host and port on the remote side.

change " <remote_server's_private_ip>" for "localhost"

Take a look at this lin, it helped me a lot eith ssh tunneling:

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.