Ansible: Adding Ansible users and SSH without SSH keys
I wanted to add a page that makes getting Ansible online a bit easier. I am assuming that you have Ubuntu 20.04 installed and have SSH already working on it.
- Adding Ansible user to target machine
- Log into target server using existing user over SSH
- Change to root user
- sudo su -
- Add new user
- adduser <user>
- Follow wizard
- Change user access for sudo
- usermod -aG sudo <user>
- Change to that user
- su <user>
- cd ~
- Generate SSH key
- ssh-keygen
- Adding user data to Ansible host file. I am assuming you have already set up your Ansible host file.
- Edit the host file
- sudo nano /etc/ansible/hosts
- Add this block to the bottom of the file.
[all:vars]
ansible_python_interpreter=/usr/bin/python3
ansible_user=<user>
ansible_ssh_pass=<user password>
- Test
- ansible -m ping <target host IP>
- Profit
SideNote: This is best used only in secure environments as anyone with access to this server can do bad things on your servers. USE WITH CAUTION!!!
Comments
Post a Comment