W3cubDocs

/Ansible 2.11

community.general.ssh_config – Manage SSH config for user

Note

This plugin is part of the community.general collection (version 2.0.1).

To install it use: ansible-galaxy collection install community.general.

To use it in a playbook, specify: community.general.ssh_config.

New in version 2.0.0: of community.general

Synopsis

  • Configures SSH hosts with special ``IdentityFile``s and hostnames.

Requirements

The below requirements are needed on the host that executes this module.

  • StormSSH

Parameters

Parameter Choices/Defaults Comments
group
string
Which group this configuration file belongs to.
If none given, user is used.
host
string / required
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 hostname.
hostname
string
The actual host to connect to when connecting to the host defined.
identity_file
path
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 0600 to be valid.
port
string
The actual port to connect to when connecting to the host defined.
proxycommand
string
Sets the ProxyCommand option.
remote_user
string
Specifies the user to log in as.
ssh_config_file
path
SSH config file.
If user and this option are not specified, /etc/ssh/ssh_config is used.
Mutually exclusive with user.
state
string
    Choices:
  • present
  • absent
Whether a host entry should exist or not.
strict_host_key_checking
string
    Choices:
  • yes
  • no
  • ask
Whether to strictly check the host key when doing connections to the remote host.
user
string
Which user account this configuration file belongs to.
If none given and ssh_config_file is not specified, /etc/ssh/ssh_config is used.
If a user is given, ~/.ssh/config is used.
Mutually exclusive with ssh_config_file.
user_known_hosts_file
string
Sets the user known hosts file option.

Notes

Note

  • Supports check mode.

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 Returned Description
hosts_added
list / elements=string
success
A list of host added.

Sample:
['example.com']
hosts_change_diff
list / elements=string
on change
A list of host diff changes.

Sample:
[{'example.com': {'new': {'hostname': 'github.com', 'identityfile': ['/tmp/test_ssh_config/fake_id_rsa'], 'port': '2224'}, 'old': {'hostname': 'github.com', 'identityfile': ['/tmp/test_ssh_config/fake_id_rsa'], 'port': '2224'}}}]
hosts_changed
list / elements=string
success
A list of host changed.

Sample:
['example.com']
hosts_removed
list / elements=string
success
A list of host removed.

Sample:
['example.com']


Authors

  • Björn Andersson (@gaqzi)
  • Abhijeet Kasurde (@Akasurde)

© 2012–2018 Michael DeHaan
© 2018–2021 Red Hat, Inc.
Licensed under the GNU General Public License version 3.
https://docs.ansible.com/ansible/2.11/collections/community/general/ssh_config_module.html