Advertisement
nRnYqfrb5pJuTP5YAohj

https://www.howtoforge.com/tutorial/setup-new-user-and-ssh-k

Nov 29th, 2018
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
YAML 1.62 KB | None | 0 0
  1. This is the valid yaml for the article given here...
  2. https://www.howtoforge.com/tutorial/setup-new-user-and-ssh-key-authentication-using-ansible/
  3. Copy and paste everything between the cut lines, ready for Ansible usage.
  4. ---------8<---------8<---------8<---------8<---------8<---------8<---------8<---------8<---------8<---------
  5. ---
  6. -
  7.   hosts: all
  8.   vars:
  9.     -
  10.       provision_password: '$6$w9S3t7x1kRtmG0u$6nVU9KZsC12Q8DYI4FtgKPy.e/cq/jseB/.DViTO1SpUnoCy.dxcOf8hyfitGq5V0yhgXccxzlqm2o.I3SlDJ0'
  11.   gather_facts: false
  12.   remote_user: root
  13.  
  14.   tasks:
  15.     -
  16.       name: "Add a new user named provision"
  17.       user: "name=provision password={{ provision_password }}"
  18.     -
  19.       copy:
  20.         content: "provision  ALL=(ALL)  NOPASSWD: ALL"
  21.         dest: /etc/sudoers.d/provision
  22.       name: "Add provision user to the sudoers"
  23.     -
  24.       authorized_key: "user=provision key=\"{{ lookup('file', '/home/provision/.ssh/id_rsa.pub') }}\" state=present"
  25.       name: "Deploy SSH Key"
  26.     -
  27.       lineinfile: "dest=/etc/ssh/sshd_config regexp='^PasswordAuthentication' line=\"PasswordAuthentication no\" state=present backup=yes"
  28.       name: "Disable Password Authentication"
  29.       notify:
  30.         - "restart ssh"
  31.     -
  32.       lineinfile: "dest=/etc/ssh/sshd_config regexp='^PermitRootLogin' line=\"PermitRootLogin no\" state=present backup=yes"
  33.       name: "Disable Root Login"
  34.       notify:
  35.         - "restart ssh"
  36.  
  37.   handlers:
  38.     -
  39.       name: "restart ssh"
  40.       service: "name=sshd state=restarted"
  41. ---------8<---------8<---------8<---------8<---------8<---------8<---------8<---------8<---------8<---------
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement