Created
November 7, 2022 17:57
-
-
Save alex27riva/e63822b525da243853b2a1cb59f24f8e to your computer and use it in GitHub Desktop.
Configure SSH under Tor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
- 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