linux.sh 838 B

123456789101112131415161718192021222324
  1. #!/bin/bash
  2. echo "Install sudo"
  3. dnf -y install sudo
  4. echo "Creating group"
  5. groupadd Ansible
  6. echo "Creating user"
  7. useradd -g Ansible -m -r -c "Ansible user" ansible
  8. echo "Set sudo rights"
  9. echo "%Ansible ALL=(ALL) NOPASSWD: ALL" > /etc/sudoers.d/Ansible
  10. echo "Set remote access"
  11. mkdir /home/ansible/.ssh
  12. chmod 700 /home/ansible/.ssh
  13. curl -o /home/ansible/.ssh/authorized_keys https://git.xo.nl/marcel/deployment/raw/master/ansible.pub
  14. chown -R ansible:Ansible /home/ansible/.ssh
  15. echo "Disable SELinux"
  16. sed -i 's/SELINUX=enforcing/SELINUX=permissive/' /etc/selinux/config
  17. setenforce 0
  18. echo "Disable root login"
  19. sed -i 's/PermitRootLogin yes/PermitRootLogin no/' /etc/ssh/sshd_config
  20. sed -i 's/PermitRootLogin without-password/PermitRootLogin no/' /etc/ssh/sshd_config
  21. echo "Deployment is completed, system reboot in 5 seconds"
  22. sleep 5
  23. reboot