community.general.ssh_config module – Manage SSH config for user
Note
This module is part of the community.general collection (version 9.4.0).
It is not included in ansible-core
.
To check whether it is installed, run ansible-galaxy collection list
.
To install it, use: ansible-galaxy collection install community.general
.
You need further requirements to be able to use this module,
see Requirements for details.
To use it in a playbook, specify: community.general.ssh_config
.
New in community.general 2.0.0
Synopsis
Configures SSH hosts with special
IdentityFile
s and hostnames.
Requirements
The below requirements are needed on the host that executes this module.
paramiko
Parameters
Parameter |
Comments |
---|---|
Sets the Choices:
|
|
Sets the Choices:
|
|
Sets the |
|
Sets the |
|
Sets the Choices:
|
|
Which group this configuration file belongs to. If none given, |
|
The endpoint this configuration is valid for. Can be an actual address on the internet or an alias that will connect to the value of |
|
Sets the |
|
The actual host to connect to when connecting to the host defined. |
|
Specifies that SSH should only use the configured authentication identity and certificate files (either the default files, or those explicitly configured in the Choices:
|
|
The path to an identity file (SSH private key) that will be used when connecting to this host. File need to exist and have mode |
|
The actual port to connect to when connecting to the host defined. |
|
Sets the Mutually exclusive with |
|
Sets the Mutually exclusive with |
|
Specifies the user to log in as. |
|
Whether a host entry should exist or not. Choices:
|
|
Whether to strictly check the host key when doing connections to the remote host. The value Choices:
|
|
Which user account this configuration file belongs to. If none given and If a user is given, Mutually exclusive with |
|
Sets the user known hosts file option. |
Attributes
Attribute |
Support |
Description |
---|---|---|
Support: full |
Can run in |
|
Support: none |
Will return details on what has changed (or possibly needs changing in |
Examples
- name: Add a host in the configuration
community.general.ssh_config:
user: akasurde
host: "example.com"
hostname: "github.com"
identity_file: "/home/akasurde/.ssh/id_rsa"
port: '2223'
state: present
- name: Delete a host from the configuration
community.general.ssh_config:
ssh_config_file: "{{ ssh_config_test }}"
host: "example.com"
state: absent
Return Values
Common return values are documented here, the following are the fields unique to this module:
Key |
Description |
---|---|
A list of host added. Returned: success Sample: |
|
A list of host diff changes. Returned: on change Sample: |
|
A list of host changed. Returned: success Sample: |
|
A list of host removed. Returned: success Sample: |