Skip to content

Instantly share code, notes, and snippets.

@Pandiora
Forked from tsabat/port_forward.md
Created March 26, 2020 06:27
Show Gist options
  • Select an option

  • Save Pandiora/378aab070ea7eb21a3945401b5a23fa5 to your computer and use it in GitHub Desktop.

Select an option

Save Pandiora/378aab070ea7eb21a3945401b5a23fa5 to your computer and use it in GitHub Desktop.

Revisions

  1. @tsabat tsabat revised this gist Aug 6, 2013. 1 changed file with 6 additions and 0 deletions.
    6 changes: 6 additions & 0 deletions port_forward.md
    Original file line number Diff line number Diff line change
    @@ -1,5 +1,11 @@
    We hide the services behind an AWS Security Group. But, we can use some trusty SSH action to forward localhost ports to those on the Solr server.

    After you've added this to your `~/.zshrc` or `~/.bash_profile` and sourced (`source ~/.bash_profile`) it, you can forward these ports from localhost to your server like so:

    ```bash
    portforward <hostname>
    ```

    zsh and bash handle string splitting differently, so be sure to choose correctly for your shell.

    For zsh:
  2. @tsabat tsabat revised this gist Aug 6, 2013. 1 changed file with 2 additions and 4 deletions.
    6 changes: 2 additions & 4 deletions port_forward.md
    Original file line number Diff line number Diff line change
    @@ -17,14 +17,12 @@ SOLR_PORTS="8080 9292 2812"
    for both shells

    ```bash
    SOLR_SERVER=<your_server_here>


    function portforward() {
    SERVER=$1
    for port in $SOLR_PORTS
    do
    echo "forwarding $port"
    ssh -l ubuntu $SOLR_SERVER -p 22 -N -f -C -L $port":localhost:"$port
    ssh -l ubuntu $SERVER -p 22 -N -f -C -L $port":localhost:"$port
    done
    }

  3. @tsabat tsabat revised this gist May 15, 2013. 1 changed file with 3 additions and 1 deletion.
    4 changes: 3 additions & 1 deletion port_forward.md
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,6 @@
    combine the two scripts below.
    We hide the services behind an AWS Security Group. But, we can use some trusty SSH action to forward localhost ports to those on the Solr server.

    zsh and bash handle string splitting differently, so be sure to choose correctly for your shell.

    For zsh:

  4. @tsabat tsabat created this gist May 15, 2013.
    37 changes: 37 additions & 0 deletions port_forward.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,37 @@
    combine the two scripts below.

    For zsh:

    ```bash
    SOLR_PORTS=(8080 9292 2812)
    ```

    for bash:

    ```bash
    SOLR_PORTS="8080 9292 2812"
    ```

    for both shells

    ```bash
    SOLR_SERVER=<your_server_here>


    function portforward() {
    for port in $SOLR_PORTS
    do
    echo "forwarding $port"
    ssh -l ubuntu $SOLR_SERVER -p 22 -N -f -C -L $port":localhost:"$port
    done
    }

    function portforwardend() {
    for port in $SOLR_PORTS
    do
    spec="\-L $port"":localhost:"$port
    echo "unforwarding $spec"
    ps aux | grep $spec | grep -v grep | awk '{print $2}' | xargs kill
    done
    }
    ```