{"id":26295520,"url":"https://github.com/khalil-as/ansible_user_ssh_conf","last_synced_at":"2026-05-19T03:07:23.945Z","repository":{"id":280614099,"uuid":"942580338","full_name":"Khalil-AS/ansible_user_ssh_conf","owner":"Khalil-AS","description":"Create a user \u0026 configure SSH Key for a user","archived":false,"fork":false,"pushed_at":"2025-04-03T07:16:26.000Z","size":71,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-03T08:25:43.811Z","etag":null,"topics":["ansible-role","configuration","ssh-key","user-authentication"],"latest_commit_sha":null,"homepage":"","language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Khalil-AS.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2025-03-04T10:29:32.000Z","updated_at":"2025-04-03T07:16:30.000Z","dependencies_parsed_at":"2025-03-12T01:34:52.974Z","dependency_job_id":"78bdfdef-a283-4aae-9ef0-1f6b564f7a5d","html_url":"https://github.com/Khalil-AS/ansible_user_ssh_conf","commit_stats":null,"previous_names":["kharune/ansible_user_ssh_conf","khalil-as/ansible_user_ssh_conf"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/Khalil-AS/ansible_user_ssh_conf","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Khalil-AS%2Fansible_user_ssh_conf","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Khalil-AS%2Fansible_user_ssh_conf/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Khalil-AS%2Fansible_user_ssh_conf/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Khalil-AS%2Fansible_user_ssh_conf/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Khalil-AS","download_url":"https://codeload.github.com/Khalil-AS/ansible_user_ssh_conf/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Khalil-AS%2Fansible_user_ssh_conf/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266770711,"owners_count":23981611,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-07-23T02:00:09.312Z","response_time":66,"last_error":null,"robots_txt_status":null,"robots_txt_updated_at":null,"robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ansible-role","configuration","ssh-key","user-authentication"],"created_at":"2025-03-15T04:14:18.331Z","updated_at":"2026-05-19T03:07:23.912Z","avatar_url":"https://github.com/Khalil-AS.png","language":"Shell","funding_links":[],"categories":[],"sub_categories":[],"readme":"🚀 **Ansible Role: User SSH Configuration**\n\n📌 **Overview**\n\nThis Ansible role automates the creation and configuration of an SSH user with key-based authentication. It ensures secure access by generating an SSH key, setting up a user, and configuring sudo privileges to allow running hands-off Playbook.\n\n✅ **Features**\n\n✔️ Generates an SSH key pair for secure authentication\n\n✔️ Creates an SSH user with a hashed password\n\n✔️ Adds the SSH key to the authorized_keys file\n\n✔️ Grants the user sudo privileges without a password\n\n✔️ Ensures correct permissions on SSH-related files\n\n📋 Prerequisites\n\n🛠 Supported Operating Systems (Tested)\n\n    Debian 12+\n\n⚙️ Required Dependencies\n\n    Ensure the control machine has:\n\n      Ansible-core 2.15.13\n\n      Python 3.9.21\n      \n      Paramiko 3.5.1\n\n      Ansible collection community.crypto\n\n    Ensure the target machine has:\n\n      Internet access (for package downloads)\n      \n      Python 3.11.2\n\n🔑 Privileges\n\nRun playbooks as a user with sudo privileges and SSH passwor auth.\n\nIn this role, the default user is control.\n\n🚀 Quick Start Guide\n\n1️⃣ Install the Role\n\n    Clone this repository :\n\n    git clone https://github.com/Kharune/ansible_user_ssh_conf.git\n    cd ansible-role-user-ssh\n\n2️⃣ Configure Inventory, Playbook, and Ansible Configuration\n\nBefore running the playbook, ensure the following files are properly configured based on your environment.\n\nInventory Configuration (hosts.yml)\n\n    lab:\n      vars:\n        ansible_python_interpreter: auto_silent\n      hosts:\n        192.168.253.130:22450  # Change this based on your environment\n    preprod:\n      children:\n        lab:\n\nPlaybook Configuration (PB_deploy_ssh.yml)\n\n    ---\n    - name: Configure SSH User with Key-Based Authentication\n      hosts: preprod  # Change this based on your target group\n      remote_user: admk  # Change this based on your user\n      become: true\n    \n      vars_files:\n        - vars/secrets.yml  # Load encrypted variables (e.g., ssh_password)\n    \n      roles:\n        - user_ssh_conf\n\nAnsible Configuration (ansible.cfg)\n\nEnsure your Ansible configuration is set correctly:\n\n    [defaults]\n    inventory=/home/control/ansible_user_ssh_conf/hosts.yml  # Change to your inventory file\n    transport=paramiko  # Change if you don't use paramiko\n\n3️⃣ Run the Playbook\n\nRun the playbook:\n\n    ansible-playbook basic_config_srv_linux.yml --ask-vault-password\n\n⚙️ Role Variables\n\nCustomize the user created and key parameters by modifying (defaults/main.yml):\n    \n    # SSH user created\n    ssh_user: control\n        \n    # SSH key settings\n    ssh_key_type: ed25519\n    ssh_key_path: \"/home/{{ ssh_user }}/.ssh/id_{{ ssh_key_type }}\"\n\n    # ssh_password: \"sha521!!\" # ansible-vault in use, path (vars/secrets.yml) password in vault_pass.txt\n\n\n**Demo**\n\n\nhttps://github.com/user-attachments/assets/04246485-50b2-4a22-84c2-9f74895eb7a3\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkhalil-as%2Fansible_user_ssh_conf","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkhalil-as%2Fansible_user_ssh_conf","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkhalil-as%2Fansible_user_ssh_conf/lists"}