Skip to content

Instantly share code, notes, and snippets.

@alex27riva
Created November 7, 2022 17:57
Show Gist options
  • Save alex27riva/e63822b525da243853b2a1cb59f24f8e to your computer and use it in GitHub Desktop.
Save alex27riva/e63822b525da243853b2a1cb59f24f8e to your computer and use it in GitHub Desktop.
Configure SSH under Tor
---
- name: Install SSH under Tor
hosts: 192.168.1.20 # add your IP or host group
become: true
vars:
- hidden_serv_dir: "/var/lib/tor/hidden_service_sshd"
tasks:
- name: Install Tor
ansible.builtin.package:
name: tor
state: present
- name: Configure Tor
ansible.builtin.lineinfile:
path: /etc/tor/torrc
owner: root
group: root
mode: '0644'
line: "{{ item }}"
loop:
- "HiddenServiceDir {{ hidden_serv_dir }}"
- "HiddenServiceVersion 3"
- "HiddenServicePort 22 127.0.0.1:22"
notify: Restart tor
- name: Read onion address
ansible.builtin.slurp:
src: "{{ hidden_serv_dir }}/hostname"
register: onion_address
tags: address
- name: Print onion address
ansible.builtin.debug:
msg: "{{ onion_address['content'] }}"
tags: address
handlers:
- name: Restart tor
ansible.builtin.service:
name: tor.service
state: restarted
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment