morikules
morikules

Reputation: 21

Ansible issue with ssh authentication

i have searched around this problem for a while now but didnt find anything that helps.

We are using ansible to automate our Juniper devices and therefore use the ansible juniper modules. When i try to use "junos_facts" for example, i can execute it without problems on host1, but on host2 i get either a PasswordRequiredException or an AuthenticationException when i add -k in the cli

TASK [proact-junos-test : Gather JunOS facts] ***************************************************************************************************************************************************
fatal: [host2]: FAILED! => {"changed": false, "msg": "PasswordRequiredException('Private key file is encrypted')"}
ok: [host1]

i tried every possible combination of parameters in cli, in ansible.cfg, in the playbook itself. For some reason it works on one host but not the other. I have deployed the same key on both host and have it stored in my ssh-agent. I can ssh to both hosts without a problem.

Can anyone help me with this? Thanks

Upvotes: 0

Views: 909

Answers (2)

morikules
morikules

Reputation: 21

For anyone having the same issue, the problem was that the remote host didn't accept my SSH key algorithm, because, since Paramiko 2.9, it was deprecated.

So, I installed Paramike 2.8.1 and it worked

Upvotes: 1

George Shuklin
George Shuklin

Reputation: 7867

As far as I can understand, the problem is that ssh key is encrypted. Try to add ssh key to ssh agent (if you have it).

If you don't have, there is a simple trick:

eval $(ssh-agent)
ssh-add path/to/private/ssh/key
ansible ...

If you are running this in CI/CD environment you'll need to fight with ssh-add about the way to ask password, but that's a different story.

Upvotes: 1

Related Questions