ansible.builtin.ssh connection – connect via SSH client binary
Note
This connection plugin is part of ansible-core
and included in all Ansible installations. In most cases, you can use the short plugin name ssh
. However, we recommend you use the Fully Qualified Collection Name (FQCN) ansible.builtin.ssh
for easy linking to the plugin documentation and to avoid conflicting with other collections that may have the same connection plugin name.
Synopsis
- This connection plugin allows Ansible to communicate to the target machines through normal SSH command line.
- Ansible does not expose a channel to allow communication between the user and the SSH process to accept a password manually to decrypt an SSH key when using this connection plugin (which is the default). The use of
ssh-agent
is highly recommended.
Parameters
Parameter | Comments |
---|---|
control_path string | This is the location to save SSH’s ControlPath sockets, it uses SSH’s variable substitution. Since 2.3, if null (default), ansible will generate a unique hash. Use ``%(directory)s`` to indicate where to use the control dir path setting. Before 2.3 it defaulted to ``control_path=%(directory)s/ansible-ssh-%%h-%%p-%%r``. Be aware that this setting is ignored if Configuration:
|
control_path_dir string | This sets the directory to use for ssh control path if the control path setting is null. Also, provides the ``%(directory)s`` variable for the control path setting. Default: Configuration:
|
host string | Hostname/IP to connect to. Default: Configuration:
|
host_key_checking boolean | Determines if SSH should reject or not a connection after checking host keys. Choices:
Configuration:
|
password string | Authentication password for the Configuration:
|
pipelining boolean | Pipelining reduces the number of connection operations required to execute a module on the remote server, by executing many Ansible modules without actual file transfers. This can result in a very significant performance improvement when enabled. However this can conflict with privilege escalation (become). For example, when using sudo operations you must first disable ‘requiretty’ in the sudoers file for the target hosts, which is why this feature is disabled by default. Choices:
Configuration:
|
pkcs11_provider string added in ansible-core 2.12 | PKCS11 SmartCard provider such as opensc, example: /usr/local/lib/opensc-pkcs11.so Requires sshpass version 1.06+, sshpass must support the -P option. Default: Configuration:
|
port integer | Remote port to connect to. Configuration:
|
private_key_file string | Path to private key file to use for authentication. Configuration:
|
reconnection_retries integer | Number of attempts to connect. Ansible retries connections only if it gets an SSH error with a return code of 255. Any errors with return codes other than 255 indicate an issue with program execution. Default: Configuration:
|
remote_user string | User name with which to login to the remote server, normally set by the remote_user keyword. If no user is supplied, Ansible will let the SSH client binary choose the user as it normally. Configuration:
|
scp_executable string | This defines the location of the scp binary. It defaults to Default: Configuration:
|
scp_extra_args string | Extra exclusive to the Default: Configuration:
|
sftp_batch_mode boolean | TODO: write it Choices:
Configuration:
|
sftp_executable string | This defines the location of the sftp binary. It defaults to Default: Configuration:
|
sftp_extra_args string | Extra exclusive to the Default: Configuration:
|
ssh_args string | Arguments to pass to all SSH CLI tools. Default: Configuration:
|
ssh_common_args string | Common extra args for all SSH CLI tools. Default: Configuration:
|
ssh_executable string | This defines the location of the SSH binary. It defaults to This option is usually not required, it might be useful when access to system SSH is restricted, or when using SSH wrappers to connect to remote hosts. Default: Configuration:
|
ssh_extra_args string | Extra exclusive to the SSH CLI. Default: Configuration:
|
ssh_transfer_method string | Preferred method to use when transferring files over ssh Choices:
Configuration:
|
sshpass_prompt string added in ansible-base 2.10 | Password prompt that sshpass should search for. Supported by sshpass 1.06 and up. Defaults to Default: Configuration:
|
timeout integer | This is the default amount of time we will wait while establishing an SSH connection. It also controls how long we can wait to access reading the connection once established (select on the socket). Default: Configuration:
|
use_tty boolean | add -tt to ssh commands to force tty allocation. Choices:
Configuration:
|
Notes
Note
- This plugin is mostly a wrapper to the ``ssh`` CLI utility and the exact behavior of the options depends on this tool. This means that the documentation provided here is subject to be overridden by the CLI tool itself.
- Many options default to
None
here but that only means we do not override the SSH tool’s defaults and/or configuration. For example, if you specify the port in this plugin it will override anyPort
entry in your.ssh/config
. - The ssh CLI tool uses return code 255 as a ‘connection error’, this can conflict with commands/tools that also return 255 as an error code and will look like an ‘unreachable’ condition or ‘connection error’ to this plugin.
Collection links
© 2012–2018 Michael DeHaan
© 2018–2024 Red Hat, Inc.
Licensed under the GNU General Public License version 3.
https://docs.ansible.com/ansible/latest/collections/ansible/builtin/ssh_connection.html