Ansible Connection Using non-root user.

Khemnath chauhan
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.

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

--

--

Khemnath chauhan
Khemnath chauhan

No responses yet

What are your thoughts?