First add a user:
$ sudo adduser ubuntu $ sudo usermod -aG sudo ubuntu
Edit sudoser file with
visudo (edit the sudoers file in a safe fashion).
$ sudo visudo
Add this line in the last line and save it.
ubuntu ALL=NOPASSWD: ALL
sudo -s or
sudo su - will login to root without asking password. This is also
required if you want to run ansible scripts with
(see: ansible docs).
Next thing we need to add our ssh public key to
.ssh/authorized_keys so that we can
ssh without password.
$ cd # go to home directory $ mkdir .ssh $ chmod 755 ~/.ssh # .ssh directory should have 755 permissions and be owned by the user $ touch authorized_keys $ chmod 644 ~/.ssh/authorized_keys # authorized_keys file should have 644 permissions and be owned by the user $ nano .ssh/authorized_keys
Copy and paste your public ssh key into
.ssh/authorized_keys and save it. That is it.