Giter VIP home page Giter VIP logo

Comments (2)

lento234 avatar lento234 commented on June 18, 2024

Content: https://github.com/geerlingguy/turing-pi-2-cluster/blob/master/tasks/networking/reverse-tunnel.yml

# See: https://www.jeffgeerling.com/blog/2022/ssh-and-http-raspberry-pi-behind-cg-nat
- name: Configure node 1 as a reverse tunnel for SSH and HTTP.
  hosts: control_plane
  gather_facts: false
  become: true

  vars_files:
    - ../../config.yml

  tasks:
    - name: Install autossh.
      ansible.builtin.apt:
        name: autossh
        state: present

    - name: Configure autossh defaults.
      ansible.builtin.copy:
        dest: /etc/default/autossh
        content: |
          AUTOSSH_POLL=60
          AUTOSSH_FIRST_POLL=30
          AUTOSSH_GATETIME=0
          AUTOSSH_PORT=22000
          SSH_OPTIONS="-N -R 2222:localhost:22 -R 8080:localhost:80 {{ reverse_tunnel_vps_username }}@{{ reverse_tunnel_vps_hostname }}"
    - name: Create autossh unit file.
      ansible.builtin.copy:
        dest: /lib/systemd/system/autossh.service
        content: |
          [Unit]
          Description=autossh
          Wants=network-online.target
          After=network-online.target
          [Service]
          Type=simple
          User=pi
          EnvironmentFile=/etc/default/autossh
          ExecStart=/usr/bin/autossh $SSH_OPTIONS
          Restart=always
          RestartSec=60
          [Install]
          WantedBy=multi-user.target
      register: autossh_unit

    - name: Reload systemd daemon if unit file changed.
      ansible.builtin.systemd:
        daemon_reload: true
      when: autossh_unit is changed

    - name: Ensure autossh service is running.
      ansible.builtin.systemd:
        name: autossh
        state: started
        enabled: true

from homelab.

lento234 avatar lento234 commented on June 18, 2024

Decided to use tailscale instead. close issue.

from homelab.

Related Issues (8)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.