Préparer un serveur client Ansible
Publié : 27 déc. 2021, 12:18
1) Créer la clé ssh
2) Créer le user ansible sur le serveur client
3) Copier la clé ssh
4) Ajouter l'utilisateur ansible dans les sudores du serveur client
5) Sécuriser l'utilisateur ansible pour ne pas pouvoir l'utiliser sur le serveur
Code : Tout sélectionner
ssh-keygenCode : Tout sélectionner
Generating public/private rsa key pair.
Enter file in which to save the key (/home/geekflare/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/geekflare/.ssh/id_rsa.
Your public key has been saved in /home/geekflare/.ssh/id_rsa.pub.
The key fingerprint is:
SHA256:3XDm62tzJegGm8oAmFYCyeFZovJOuU42zNgyn9GzH30 geekflare@geekflare
The key's randomart image is:
+---[RSA 2048]----+
|o+.. |
|+o+ |
|oo. . . o |
|.. * . * |
| B . S . o. |
| O o . . . ... .|
|+ @ o o . E=. o |
| B + o + .o.= . |
| + ... o. oo+ |
+----[SHA256]-----+Code : Tout sélectionner
sudo adduser --shell /bin/bash --gecos "" ansibleCode : Tout sélectionner
ssh-copy-id ansible@serveurhostCode : Tout sélectionner
sudo visudoCode : Tout sélectionner
#
# This file MUST be edited with the 'visudo' command as root.
#
# Please consider adding local content in /etc/sudoers.d/ instead of
# directly modifying this file.
#
# See the man page for details on how to write a sudoers file.
#
Defaults env_reset
Defaults mail_badpass
Defaults secure_path="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
# Host alias specification
# User alias specification
# Cmnd alias specification
# User privilege specification
root ALL=(ALL:ALL) ALL
# Allow members of group sudo to execute any command
%sudo ALL=(ALL:ALL) ALL
ansible ALL=(ALL) NOPASSWD:ALL
# See sudoers(5) for more information on "@include" directives:
@includedir /etc/sudoers.dCode : Tout sélectionner
sudo usermod -L ansible