ssh-copy-id in ansible

ssh-copy-id is a command-line tool used to copy your public SSH key to a remote server's authorized_keys file, allowing you to log in to the server without entering a password.

Ansible is an open-source automation tool used to manage and configure multiple remote servers simultaneously. In Ansible, you can use the authorized_key module to manage the authorized keys of remote servers. This module allows you to add, remove, or replace SSH keys in a remote user's authorized_keys file.

To add your public SSH key to a remote server using Ansible, you can use the authorized_key module. Here's an example playbook that adds your public SSH key to a remote server's authorized_keys file:

- name: Add SSH key to authorized_keys
  hosts: your_server
  become: true
  tasks:
    - name: Install SSH key for current user
      authorized_key:
        user: your_username
        key: "{{ lookup('file', '/path/to/your/public/key/id_rsa.pub') }}"

In this example, replace your_server with the hostname or IP address of the remote server, your_username with the username of the remote user, and /path/to/your/public/key/id_rsa.pub with the path to your public SSH key file.

When you run this playbook, Ansible will use the authorized_key module to add your public SSH key to the authorized_keys file of the specified remote user. Once the key has been added, you will be able to log in to the remote server without entering a password.

댓글

이 블로그의 인기 게시물

Using the MinIO API via curl

Fundamentals of English Grammar #1

리눅스의 부팅과정 (프로세스, 서비스 관리)

How to checkout branch of remote git, 깃 리모트 브랜치 체크아웃

urllib3 with proxy settings

In HBase, the "memory to disk" flush operation

Chromium 개발 환경 세팅, 크로미움 개발 준비하기

To download a file from MinIO using Spring Boot, 스프링부트 Minio 사용하기

CDPEvents in puppeteer

To build a gRPC service with Gradle, Java, and Avro