Bachelor Tech
  • Home
  • Tutorials
  • Tips
  • Portfolio
  • About Jan
  • Contact Jan

2. Set up SSH keys for password-less access to your hosts

by Jan Bachelor November 13, 2025

We need to create SSH keys and get the public parts deployed to the individual hosts. The challenge here is that the actual Ansible jobs will be run by the awx-instance-task pod, which is a container running inside Kubernetes. This pod needs to have its own private key (so creating one on the VM would not have an impact on it).

We will therefore firstly need to create a key on the VM, deploy it to each host and then add it to AWX for the task pod to use.

  • On our VM, create a temporary key:
# 1. Create the key. Use -N "" for no passphrase (AWX needs this)
ssh-keygen -t ed25519 -f $HOME/.ssh/awx_key -N ""

# 2. Display the PUBLIC key. Copy this entire line to your clipboard.
cat $HOME/.ssh/awx_key.pub
  • This is the manual, lengthy part if you have a lot of VMs and containers – run this on each to get the key over.
# 1. Create the 'ansible' user with no password.
# -m creates the /home/ansible directory.
# -s /bin/bash sets their shell.
sudo useradd -m -s /bin/bash ansible

# Lock the user - disable password-based login
sudo passwd -l ansible

# 2. Give the user passwordless sudo
sudo visudo
# Add this line at the very end of the file. Save and exit.
ansible ALL=(ALL) NOPASSWD: ALL

# 3. Create the .ssh directory and file as the 'ansible' user
sudo -u ansible mkdir /home/ansible/.ssh
sudo -u ansible chmod 700 /home/ansible/.ssh
sudo -u ansible touch /home/ansible/.ssh/authorized_keys
sudo -u ansible chmod 600 /home/ansible/.ssh/authorized_keys

# 4. Open the file and paste your key
sudo -u ansible nano /home/ansible/.ssh/authorized_keys
ssh-ed25519 your-public-key

# Paste the key from the clipboard. Save & exit.
  • Rinse and repeat (including your Proxmox hosts) until you reach all your hosts that you want to manage! Got a non-Linux OS? See below.

Troubleshooting different OS/situations

  • In case you the sudo visudo command does not work on Linux:
sudo apt install sudo -y # Debian/Ubuntu
  • For hosts that are not Linux-based, such as FreeBSD (on OPNSense, select option 8 to get to Shell first):
pkg install sudo

adduser
- Username: ansible
- Full name: Ansible Service User
- Uid (Leave empty for default): (Press Enter)
- Login group [ansible]: **wheel**
- Invite ansible into other groups? []: (Press Enter)
- Login class [default]: (Press Enter)
- Shell [sh]: (Press Enter)
- Home directory [/home/ansible]: (Press Enter)
- Home directory permissions (Leave empty for default): (Press Enter)
- Use password-based authentication? [yes]: **no** (This will disable password login)
- Lock out the account after creation? [no]: (Press Enter)
- OK? [yes/no]: yes
- Add another user? (yes/no) [no]: no

visudo
# Here add the row. Most likely, you will be using 'vi' - press 'a' for insert mode
# Find the row, insert the text:
ansible ALL=(ALL) NOPASSWD: ALL
# Then press Escape, followed by typing :wq 
# followed by enter. To exit without saving, type :q!

# Set up folder/file permissions
mkdir /home/ansible/.ssh
chmod 700 /home/ansible/.ssh
touch /home/ansible/.ssh/authorized_keys
chmod 600 /home/ansible/.ssh/authorized_keys
chown -R ansible:wheel /home/ansible/.ssh
Get your Ansible user and SSH key imported for each of your hosts - this is how you handle it on FreeBSD with OPNSense.
How to add the Ansible user on FreeBSD (OPNSense)
1. Install AWX on K3s (Debian)
3. Optional: Create virtual IP with load balancing for your Proxmox cluster
Go back to course overview: Deploy Ansible AWX to automate OS patching

Leave a Comment Cancel Reply

Save my name, email, and website in this browser for the next time I comment.

This site uses Akismet to reduce spam. Learn how your comment data is processed.

0 FacebookWhatsappEmail

Course Steps

  1. 1. Install AWX on K3s (Debian)
  2. 2. Set up SSH keys for password-less access to your hosts
  3. 3. Optional: Create virtual IP with load balancing for your Proxmox cluster
  4. 4. Create a custom Execution Environment (EE)
  5. 5. Set Up Proxmox Auto Discovery
  6. 6. Set up your first OS patching job!
  7. 7. Useful Patch Management Ansible Templates for your Hosts
  8. 8. Conclusion - Next Steps & Alternatives to AWX

Other courses

Create an automated Gravity workflow that will allow...

January 19, 2024

Dynamically Populate Gravity Forms from Google Sheets (GSheets...

March 16, 2021

Concur Alternative: Import Employees’ Credit Card Expenses to...

January 19, 2024

Turn your Raspberry Pi into a Proxmox Backup...

July 13, 2025

Install iRedMail Mail Server As Proxmox VM With...

October 31, 2024

Recent Posts

  • How to get LXC containers for Proxmox outside of ready-made templates

  • How to join two Proxmox nodes into a cluster (PVE 8.x)

  • How to Rename a Proxmox Node

Facebook Twitter Instagram Pinterest Linkedin Youtube

All Rights Reserved. The theme was customized from Soledad, see PenciDesign

Bachelor Tech
  • Home
  • Tutorials
  • Tips
  • Portfolio
  • About Jan
  • Contact Jan