Skip to content

Commit 56090ff

Browse files
authored
Merge pull request #135 from thaim/ssh-refactor
Refactor ssh related role
2 parents 7a7f2eb + a8b867d commit 56090ff

File tree

6 files changed

+40
-333
lines changed

6 files changed

+40
-333
lines changed

playbook-desktop.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
roles:
55
- { role: git, tags: git, GIT_INSTALLER: 'extra' }
66
- { role: shell, tags: shell, SHELL_TYPE: 'bash' }
7+
- { role: ssh, tags: ssh }
78
- { role: fonts, tags: fonts }
89
- { role: golang, tags: golang }
910
- { role: aqua, tags: aqua }

roles/secure-sshd/files/sshd_config

Lines changed: 0 additions & 157 deletions
This file was deleted.

roles/secure-sshd/tasks/main.yml

Lines changed: 0 additions & 5 deletions
This file was deleted.

roles/ssh/files/sshd_config

Lines changed: 0 additions & 153 deletions
This file was deleted.

roles/ssh/tasks/main.yml

Lines changed: 39 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,41 @@
11
---
22

3-
- name: ssh | Deny Root login
4-
sudo: yes
5-
lineinfile: dest=/etc/ssh/sshd_config
6-
regexp="PermitRootLogin"
7-
line="PermitRootLogin no"
8-
insertafter="# Authentication:"
3+
# ssh config
4+
5+
- name: Get SSH client version
6+
ansible.builtin.shell: |
7+
set -o pipefail
8+
ssh -V 2>&1 | head -n1 | sed 's/.*_\([0-9]\+\.[0-9]\+\).*/\1/'
9+
register: ssh_version_output
10+
changed_when: false
11+
12+
- name: Set SSH version fact
13+
ansible.builtin.set_fact:
14+
ssh_version: "{{ ssh_version_output.stdout | float }}"
15+
16+
- name: Ensure .ssh directory exists
17+
ansible.builtin.file:
18+
path: "{{ ansible_env.HOME }}/.ssh"
19+
state: directory
20+
mode: '0700'
21+
22+
- name: Configure ObscureKeystrokeTiming for SSH versions < 10.0
23+
ansible.builtin.blockinfile:
24+
path: "{{ ansible_env.HOME }}/.ssh/config"
25+
block: |
26+
Host *
27+
ObscureKeystrokeTiming no
28+
marker: "# {mark} ANSIBLE MANAGED BLOCK - ObscureKeystrokeTiming"
29+
create: yes
30+
mode: '0600'
31+
when: ssh_version < 10.0
32+
33+
# sshd config
34+
35+
- name: Deny root login
36+
become: yes
37+
ansible.builtin.lineinfile:
38+
dest: /etc/ssh/sshd_config
39+
regexp: "PermitRootLogin"
40+
line: "PermitRootLogin no"
41+
insertafter: "# Authentication:"

roles/ssh_hosts/tasks/main.yml

Lines changed: 0 additions & 12 deletions
This file was deleted.

0 commit comments

Comments
 (0)