update ssh task + readme
This commit is contained in:
parent
12aeb27b19
commit
0de8330fd2
12
README.md
12
README.md
@ -15,7 +15,7 @@ Ce playbook installe les services suivant:
|
||||
|
||||
## PRE REQUIS
|
||||
|
||||
- Debian 11
|
||||
- Debian 12
|
||||
|
||||
- Accès au serveur en ssh (username sudo, password)
|
||||
|
||||
@ -25,6 +25,14 @@ Ce playbook installe les services suivant:
|
||||
sudo apt install ansible -y
|
||||
```
|
||||
|
||||
## CONFIGURATION
|
||||
|
||||
- Editer le fichier `vars.yml` et renseigner le `user`, `ssh_port` et l'`admin_email`
|
||||
|
||||
- Ajouter une clé SSH `ed25519` dans le dossier `files/`
|
||||
|
||||
> Cette clé permettra l'accès au serveur une fois le playbook terminé
|
||||
|
||||
## UTILISATION
|
||||
|
||||
- échanger sa clef ssh avec la machine cible avec la commande:
|
||||
@ -32,8 +40,6 @@ sudo apt install ansible -y
|
||||
ssh-copy-id username@ip-machine-cible
|
||||
```
|
||||
|
||||
- Configurer le fichier hosts avec l'adresse IP de la machine cible ainsi que sont port ssh (si non default: 22) ainsi que le port ssh utilisé dans le fichier vars.yml
|
||||
|
||||
- Lançer la commande avec les paramètres modifiés pour username, password et ssh_port
|
||||
```bash
|
||||
ansible-playbook -i hosts playbook.yml --user=username --extra-vars "ansible_sudo_pass=password user=username ssh_port=2222"
|
||||
|
||||
@ -1,3 +1,17 @@
|
||||
---
|
||||
|
||||
- name: config ssh
|
||||
- name: Deploy SSH config
|
||||
template:
|
||||
src: sshd_config.j2
|
||||
dest: /etc/ssh/sshd_config
|
||||
owner: root
|
||||
group: root
|
||||
mode: '0600'
|
||||
notify: Restart SSH
|
||||
|
||||
- name: SSH key for access
|
||||
authorized_key:
|
||||
user: "{{ user }}"
|
||||
state: present
|
||||
key: "{{ lookup('file', 'files/id_ed25519.pub') }}"
|
||||
notify: Restart SSH
|
||||
@ -0,0 +1,15 @@
|
||||
# templates/sshd_config.j2
|
||||
|
||||
Port {{ ssh_port }}
|
||||
Protocol 2
|
||||
PermitRootLogin no
|
||||
PasswordAuthentication no
|
||||
ChallengeResponseAuthentication no
|
||||
UsePAM yes
|
||||
X11Forwarding no
|
||||
ClientAliveInterval 300
|
||||
ClientAliveCountMax 2
|
||||
PermitEmptyPasswords no
|
||||
LoginGraceTime 30
|
||||
MaxAuthTries 3
|
||||
# AllowUsers {{ ssh_allowed_users | default('admin') }}
|
||||
Loading…
x
Reference in New Issue
Block a user