Skip to content

Latest commit

 

History

History
65 lines (47 loc) · 1.25 KB

README.md

File metadata and controls

65 lines (47 loc) · 1.25 KB

SSH Key Management for Ansible

This guide explains how to set up and manage SSH keys for Ansible automation.

Generate SSH Key

Run these commands from the project root:

cd credentials
ssh-keygen -t rsa -b 2048 -f "$(pwd)/ansible_hub_key"

This will create:

  • ansible_hub_key (private key)
  • ansible_hub_key.pub (public key)

Key Usage

Test SSH Connection

ssh -i ./ansible_hub_key root@your-server-ip

Setup Steps

  1. Copy the public key to your target server:

    ssh-copy-id -i ./ansible_hub_key.pub root@your-server-ip
  2. Set proper permissions:

    chmod 600 ansible_hub_key
  3. Update your .env file with the correct path:

    SSH_PRIVATE_KEY_PATH=./credentials/ansible_hub_key
    

Using AWS PEM Key

If you're using an AWS EC2 instance:

  1. Place your .pem key file in the credentials directory:

    cp /path/to/your-aws-key.pem ./credentials/
  2. Set proper permissions:

    chmod 400 ./credentials/your-aws-key.pem
  3. Update your .env file with the PEM key path:

    SSH_PRIVATE_KEY_PATH=./credentials/your-aws-key.pem
    
  4. Test the connection:

    ssh -i ./credentials/your-aws-key.pem ubuntu@your-ec2-ip