- Creates a new user
- Add to the "sudo" group
- Disable ssh access to root
- Login with ssh key only
Install:
sudo apt install ansible sshpass -y
Clone repository:
git clone https://github.com/DanteLorenzo/init_server.git
cd ./init_server
Before start ansible playbook create ssh keys:
ssh-keygen -t rsa
In inventory/hosts.ini
set your IP, uncomment and set password for root(or use -k
in command):
[servers]
srv1 ansible_host=YOUR_IP
[servers:vars]
ansible_user=root
#ansible_password=YOUR_SSH_ROOT_PASSWORD
#ansible_ssh_private_key_file="~/.ssh/id_rsa"
How you can use this command to set up server:
ansible-playbook init_server.yml -i inventory/hosts.ini -k -e "user=NEW_USER password=PASSWORD_FOR_USER"