Ansible connection via PSMP returned error message "Failed to connect to the host via ssh:"
122
Created On 11/10/26 10:59 AM - Last Modified 11/10/26 16:09 PM
Symptom
User sets up Ansible connection via PSM for SSH as per online documentation.
https://docs.cyberark.com/Product-Doc/OnlineHelp/PAS/Latest/en/Content/PASIMP/psmp_ansible.htm#UseAnsiblewithPSMforSSH
Ansible connection works without PSMP (PSM for SSH ) and user can use ssh Vualtuser@TargetUser@TargetMachine@PSMPserver command to connect to the target machine
However , Ansible connection via PSMP returned error message "Failed to connect to the host via ssh:"
There is no detailed error code behind connection failure message
More information can be retrieved by adding a -vvv parameter to the command line, for example:
ansible -i /tmp/psmp_ansible_simple_inventory.ini PSMPTargets -a "ls" -vvv
<10.0.123.38> ESTABLISH SSH CONNECTION FOR USER: administrator@root@10.0.122.121
<10.0.123.38> SSH: EXEC sshpass -d8 ssh -C -o ControlMaster=auto -o ControlPersist=60s -o 'User="administrator@root@10.0.122.121"' -o ConnectTimeout=10 -o ControlPath=/root/.ansible/cp/8a7b62a53e 10.0.123.38 '/bin/sh -c '"'"'echo '"'"'"'"'"'"'"'"'~administrator@root@10.0.122.121'"'"'"'"'"'"'"'"' && sleep 0'"'"''
<10.0.123.38> (255, 'PSPSD072E Perform session error occurred. Reason: You are required to specify more information for this operation and no terminal was allocated. Use the [-t] option to force terminal allocation, or connect with SSH through PSM For SSH to the target and then run the command.. (Codes: -1, -1)\n', '')
10.0.122.121 | UNREACHABLE! => {
"changed": false,
"msg": "Failed to connect to the host via ssh: ",
"unreachable": true
}
Environment
11.4;11.5;11.6;11.7 PSM for SSH 11.6, CentOS 7.5
Cause
By default PSM for SSH connections require user to specify and connection reason, however the terminal prompt to key in the connection reason is not available via Ansible connection.
Resolution
Disable "require users to specify reason for access" would resolve the problem.
1 Login PVWA-->Policies
2 Find Master Policy-->Privileged Access Workflows-->Require users to specify reason for access
3 Add the target account platform to exception and make it inactive
4 Click "finish" to save the change.