# Remotely access an elasticsearch server using SSH tunnel

**URL:** https://discuss.elastic.co/t/remotely-access-an-elasticsearch-server-using-ssh-tunnel/168278
**Category:** Elasticsearch
**Created:** [February 13, 2019, 7:25pm UTC](https://discuss.elastic.co/t/remotely-access-an-elasticsearch-server-using-ssh-tunnel/168278 "2019-02-13T19:25:03Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![amitnegi6190](https://avatars.discourse-cdn.com/v4/letter/a/b4bc9f/32.png) [@amitnegi6190](https://discuss.elastic.co/u/amitnegi6190)
#### Post date: [February 13, 2019, 7:25pm UTC](https://discuss.elastic.co/t/remotely-access-an-elasticsearch-server-using-ssh-tunnel/168278/1 "2019-02-13T19:25:03Z")

</div>

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](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!!!

---

<div class="post-metadata">

### Author: ![Felipe\_Villalobos\_Fo](https://avatars.discourse-cdn.com/v4/letter/f/977dab/32.png) [@Felipe\_Villalobos\_Fo](https://discuss.elastic.co/u/Felipe_Villalobos_Fo)
#### Post date: [March 9, 2019, 12:41am UTC](https://discuss.elastic.co/t/remotely-access-an-elasticsearch-server-using-ssh-tunnel/168278/2 "2019-03-09T00:41:32Z")

</div>

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:

> <https://unix.stackexchange.com/questions/46235/how-does-reverse-ssh-tunneling-work>

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)
#### Post date: [April 6, 2019, 12:41am UTC](https://discuss.elastic.co/t/remotely-access-an-elasticsearch-server-using-ssh-tunnel/168278/3 "2019-04-06T00:41:33Z")

</div>

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