Skip to content

This Ansible playbook automates the creation of SSH key pairs. It prompts the user for necessary details, checks if an SSH key already exists for the given host, and generates a new SSH key pair if it does not exist. This playbook is useful for system administrators and developers who need to set up secure SSH access for their systems.

Notifications You must be signed in to change notification settings

ClassOdUa/Ansible-Playbook-SSH-key-creator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 

Repository files navigation

Ansible Playbook to Create SSH Key Pair

This repository contains an Ansible playbook designed to automate the creation of SSH key pairs. The playbook prompts the user for necessary information, checks if an SSH key already exists for the specified host, and generates a new SSH key pair if it does not exist.

Features

  • Prompts the user for the SSH key storage folder, host name, host IP, and password for the SSH private key.
  • Checks if an SSH key already exists for the given host.
  • Generates a new SSH key pair using the specified cipher type (default: ed25519).
  • Displays the fingerprint of the generated SSH key.

Requirements

  • Ansible 2.9 or higher
  • community.crypto Ansible collection

Installation

  1. Install Ansible:
    sudo apt-get install ansible

Install the community.crypto collection:

ansible-galaxy collection install community.crypto

Usage

  1. Clone this repository:
    git clone https://github.com/yourusername/ansible-ssh-keygen.git
    cd ansible-ssh-keygen
  2. Run the playbook:
    ansible-playbook create_ssh_key.yml
  3. Follow the prompts to provide the necessary information:
  • Define the SSH key pair storage folder (default: ~/.ssh).
  • Define the host name (default: example.local).
  • Define the host IP (default: 0.0.0.0).
  • Define the password for the SSH private key.

Example

ansible-playbook create_ssh_key.yml

Define the SSH key pair storage folder: ~/.ssh
Define the Host Name: myserver.local
Define the Host IP: 192.168.1.100
Define the password for SSH Private Key: ********

License

This project is licensed under the MIT License.

Contributing

Contributions are welcome! Please open an issue or submit a pull request for any changes or enhancements.

About

This Ansible playbook automates the creation of SSH key pairs. It prompts the user for necessary details, checks if an SSH key already exists for the given host, and generates a new SSH key pair if it does not exist. This playbook is useful for system administrators and developers who need to set up secure SSH access for their systems.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published