Hello.
Now Paramiko transport use have the following logic regarding to usage
of ssh-agent (and default ~/.ssh/id_{d,r}sa keys):
ssh.connect(self.host, username=user, allow_agent=True, \
look_for_keys=True<...>
So it always uses ssh-agent first, even if password is supplied to
Ansible with -k option. Also it always tries default SSH keys [1].
This is a problem if ssh-agent stores keys with 'confirmation required'
mode (keys added with ssh-add -c). Since Ansible connects to target for
every separate task, ssh-agent asks for confirmation way too much times
for big playbooks. Despite the fact that authtorization is performed
with password and ssh-agent is not related at all.
(As a side note, this 'try everything what we can' approach can mask
errors and does not look like the best way for me even if it would not
cause troubles)
I thought that it may be reasonable to stop checking default id_{d,r}sa
keys if key or password is provided. And if password is provided, then
also stop to talk with ssh-agent.
But Paramiko can use 'password' argument to SSHClient.connect() both as
password to decrypt private key and as password to authenticate with SSH
server. So it is not clear for Ansible if password provided with -k
option is intended for authentication via SSH or as passphrase for
~/.ssh/id_rsa.
So I'm not sure what can be done here. May be separate options for
private key password and remote system SSH password, not -k for both?
Would such patch be useful for anyone and accepted?
I understand that most Ansible users are not affected. But we placed
Ansible at a central server and allow it to login to our systems by
means of agent forwarding. And so it is desirable to keep keys with
'confirmation required' mode. But tons of unneeded requests to ssh-agent
make Ansible unusable. Paramiko transport is really needed for initial
setup as native 'ssh' supports only keys, not passwords.
[1]:
http://www.lag.net/paramiko/docs/paramiko.SSHClient-class.html#connect