# could not locate file in lookup to deploy authorized\_keys

**URL:** <https://forum.ansible.com/t/could-not-locate-file-in-lookup-to-deploy-authorized-keys/31889>\
**Category:** Ansible Project\
**Created:** [December 31, 2019, 1:04am UTC](https://forum.ansible.com/t/could-not-locate-file-in-lookup-to-deploy-authorized-keys/31889 "2019-12-31T01:04:49Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![cch](https://avatars.discourse-cdn.com/v4/letter/c/898d66/32.png) [@cch](https://forum.ansible.com/u/cch)\
**Post date:** [December 31, 2019, 1:04am UTC](https://forum.ansible.com/t/could-not-locate-file-in-lookup-to-deploy-authorized-keys/31889/1 "2019-12-31T01:04:49Z")

</div>

I have a task like this

> - name: test  
> tags: key  
> authorized\_key:  
> user: “{{ item }}”  
> state: present  
> key: “{{lookup(‘file’, ‘/home/{{ item }}/.ssh/id\_rsa.pub’)}}”  
> with\_items:
> - changch  
> become\_user: “{{ item }}”

I’m sure the id\_rsa.pub exists in local ansible controller (actually, the file exists on both node )

> [minion@hqs009 ansiblecontrol]$ sudo ls -lart /home/changch/.ssh/id\_rsa.pub  
> -rw------- 1 changch root 757 Mar 23 2018 /home/changch/.ssh/id\_rsa.pub  
> [minion@hqs009 ansiblecontrol]$

but there are some error messages like this

> task path: /home/mini/D/ansiblecontrol/roles/bootstrap-1804/tasks/main.yml:113  
> Tuesday 31 December 2019 09:01:40 +0800 (0:00:04.004) 0:00:04.141 \*\*\*\*\*\*  
> [WARNING]: Unable to find ‘/home/changch/.ssh/id\_rsa.pub’ in expected paths (use -vvvvv to see paths)  
> File lookup using None as file  
> fatal: [[hqdc075.abc.com](http://hqdc075.abc.com)]: FAILED! =\> {}  
> MSG:  
> An unhandled exception occurred while running the lookup plugin ‘file’. Error was a \<class ‘ansible.errors.AnsibleError’\>, original message: could not locate file in lookup: /home/changch/.ssh/id\_rsa.pub
> 
> PLAY RECAP \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
> [hqdc075.abc.com](http://hqdc075.abc.com) : ok=1 changed=0 unreachable=0 failed=1 skipped=0 rescued=0 ignored=0

[### any advice and suggestions will be greatly appreciated](https://www.travellerspoint.com/forum.cfm?thread=14067)

---

<div class="post-metadata">

**Author:** ![Kai\_Stian\_Olstad](https://avatars.discourse-cdn.com/v4/letter/k/e19adc/32.png) [@Kai\_Stian\_Olstad](https://forum.ansible.com/u/Kai_Stian_Olstad)\
**Post date:** [December 31, 2019, 11:09am UTC](https://forum.ansible.com/t/could-not-locate-file-in-lookup-to-deploy-authorized-keys/31889/2 "2019-12-31T11:09:39Z")

</div>

If you are sure the file exist on localhost then it's much likely a permission issue.

With your sudo command you are checking with root user, root have all permission, you need to check with the same user as the playbook.

&nbsp;&nbsp;&nbsp;sudo -u changch cat /home/changch/.ssh/id\_rsa.pub
