Setup SSH Key and initial user using Ansible Playbook

Nidhi
2 min readOct 12, 2018

Check out my YouTube video on this article

Checkout my blog of using automation of setting up an initial user https://devops4solutions.com/automate-ansible-playbook-deployment-on-aws-ec2/

In this blog we will Setup SSH Key and initial user using Ansible Playbook

To create new user on ubuntu system, you need the following things:

  1. Username/Password
  2. Public Key of the user
  3. You will first create a user on one machine. Machine can be your local workstation also
  4. Generate ssh-key for this
  5. Put the public key of that user to the remote hosts.
  6. Add that user to the sudoers.d file

Steps:

sudo -i
useradd -m -s /bin/bash devops
passwd devops
echo -e ‘devops\tALL=(ALL)\tNOPASSWD:\tALL’ > /etc/sudoers.d/devops
Encrypt your password
sudo apt install whois -y
mkpasswd — method=SHA-512
TYPE THE PASSWORD ‘devops’

--

--