aboutsummaryrefslogtreecommitdiff
path: root/tasks/main.yml
diff options
context:
space:
mode:
authorFlorian Fischer <florian.fischer@muhq.space>2024-03-15 14:05:57 +0100
committerFlorian Fischer <florian.fischer@muhq.space>2024-03-15 14:05:57 +0100
commit6f576196ac7c50b2a52162a0992263ef35534425 (patch)
tree0616311626da3007dccdd2eb416bedfb2e1b6a75 /tasks/main.yml
downloadssh_relay_access-6f576196ac7c50b2a52162a0992263ef35534425.tar.gz
ssh_relay_access-6f576196ac7c50b2a52162a0992263ef35534425.zip
add initial commitHEADmain
Diffstat (limited to 'tasks/main.yml')
-rw-r--r--tasks/main.yml29
1 files changed, 29 insertions, 0 deletions
diff --git a/tasks/main.yml b/tasks/main.yml
new file mode 100644
index 0000000..2fa10e9
--- /dev/null
+++ b/tasks/main.yml
@@ -0,0 +1,29 @@
+- name: "Setup passwordless authentication from {{ ssh_relay_accessing_host }} to {{ ssh_relay_accessed_host }}"
+ block:
+ - name: Deploy ssh-relay ssh pivate key
+ delegate_to: "{{ ssh_relay_accessing_host }}"
+ ansible.builtin.copy:
+ src: "~/.ssh/{{ relay_ssh_key_name }}"
+ dest: "~/.ssh/{{ relay_ssh_key_name }}"
+ # Make the ssh private key only readable/writable for its owner
+ mode: '600'
+ no_log: true
+
+ - name: Authorize the ssh-relay key on the relay host
+ delegate_to: "{{ ssh_relay_accessed_host }}"
+ run_once: true
+ authorized_key:
+ user: "{{ ssh_relay_accessed_user }}"
+ state: present
+ key: "{{ lookup('file', relay_ssh_key_name + '.pub') }}"
+ key_options: "command=\"echo 'This identity can only be used for port forwarding'\",restrict,port-forwarding"
+
+- name: "Authorize the relay host on the {{ ssh_relay_accessing_host }}"
+ tags:
+ - ssh
+ ansible.builtin.include_role:
+ name: ssh_authorize_host
+ apply:
+ delegate_to: "{{ ssh_relay_accessing_host }}"
+ vars:
+ ssh_hostname: "{{ ssh_relay_accessed_host }}"