Remotely access an elasticsearch server using SSH tunnel

(Amit Singh) #1


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:
http.port: 9200

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

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

What am I doing wrong here?