Ansible Connection Using non-root user.
2 min readOct 2, 2023
STEPS REQUIRED :
1. ) Create a user
$ useradd -m -s /bin/bash devops
2. ) Set password
$ passwd devops
3. ) Now, this user can only perform simple tasks. We have higher privilege- we need to provide sudo privilege.
To enable this we need to update sudoers file. under /etc/sudoers ( only root user can open this file)
we can open this file from this path — /etc/sudoers . However this is not recommended. instead we can use the below command as root user.
$ visudo
Now, we can use sudo Infront of commands and do tasks same as root user. ( user will avail privilege only when use sudo)
e.g: sudo yum install httpd
4.) SSH Connection. ( With password)
- By default we can’t ssh into another node. To enable ssh connection we need to update the configuration file related to ssh.
- /etc/ssh/sshd_conf
5.) Password less SSH
In above connection (#4), every time we try to login to remote node, it will prompt for password). This is tedious and overhead when we have number of server to connect to. For this we need to setup a password less SSH connection.