When ansible-playbook is executed on the server for which SSH public key authentication has been set as shown below.
$ansible-playbook -i hosts install.yml -vvv -K
I got the following result and it freezes.
<192.168.0. *>ESTABLISH SSH CONNECTION FOR USER: yamadoc <192.168.0. *>SSH: EXEC sshpass -d11 ssh -C -o ControlMaster = auto -o ControlPersist = 60s -o Port = 1022 -o'User = "yamadoc"' -o ConnectTimeout = 10 -o ControlPath =/home/yamadoc/.ansible/cp/e559f14bc0 192.168.0. *'/ Bin/sh -c'"'"' echo ~ yamadoc&&sleep 0'"'"''
Initially, it was stopped by Gathering Fact, so I set it to false and set it not to collect, but this time, it freezes at the same place when task is executed.
Could anyone please tell me what to do?
On the target server side, it worked well before setting public key authentication, but when public key authentication is set, the above phenomenon occurs and it freezes. In addition, sshpass has already been installed on the target server side.
I didn't set host_key_checking, so I added the settings as follows, but it didn't change.
# uncomment this to disable SSH key host checking host_key_checking = False
Even if I execute ansible -m ping 192.168.0. * -Vvv, pong does not return properly. The same phenomenon happened and it freezes.
After freezing, no error is displayed as it is. When I ran ansible-config view, it became as follows.
$ansible-config view (abridgement) host_key_checking = False (abridgement)
I also tried to run ansible-playbook again with the following settings, but it remained frozen.
ssh_args = -C -o ControlMaster = auto -o ControlPersist = 60s -o StrictHostKeyChecking = no -o UserKnownHostsFile =/dev/null
It will freeze at the following locations.
<192.168.0. *>ESTABLISH SSH CONNECTION FOR USER: yamadoc <192.168.0. *>SSH: EXEC sshpass -d11 ssh -vvv -C -o ControlMaster = auto -o ControlPersist = 60s -o StrictHostKeyChecking = no -o UserKnownHostsFile =/dev/null -o StrictHostKeyChecking = no -o Port = 1022 -o'User = "yamadoc"' -o ConnectTimeout = 10 -o ControlPath =/home/yamadoc/.ansible/cp/e559f14bc0 192.168.0.18'/ bin/sh -c'"'"' echo ~ yamadoc&&sleep 0'"'"''
I've also tried removing ~/.ansible, but it still doesn't work.
Postscript as of 20201126:
When I executed the following command on the target server side, it was waiting for input and it froze as it was.
sshpass -d11 ssh -vvv -C -o ControlMaster = auto ~ omitted ~
I tried using ssh-agent and it was solved successfully. Regarding this, I will describe the details to the self-solving person.
We apologize for the inconvenience, but thanks for your cooperation.
Answer # 1
On the Ubuntu side running Ansible, I tried using ssh-agent and it was solved.
First, execute ssh-agent and register the private key.
Run ssh-agent $eval `ssh-agent` Registering private key and passphrase with ssh-add $ssh-add private key path Confirmation of private key registration $ssh-add -l
When I ran ansible-playbook in this state, it was completed successfully without freezing.
Thank you for your advice while you are busy.
- linux : To connect to a host that automatically performs an interactive installation when connecting with Ansible
- how to install oracle jdk 8 with ansible
- i cannot connect to linux (centos7) installed on virtulbox from the host machine by ssh
- centos - ssh key authentication access permission denied
- centos - permission denied with ssh key authentication access
- php - i don't understand about ssh public key
- i can't connect to centos 8 with ssh
- python - when i run ansible-playbook, there is no particular error, but nothing happens on the client side
- nginx - development environment construction with vagrant and virtualbox