# bug in authorized\_keys module?

**URL:** <https://forum.ansible.com/t/bug-in-authorized-keys-module/13346>\
**Category:** Ansible Project\
**Created:** [August 21, 2013, 7:16pm UTC](https://forum.ansible.com/t/bug-in-authorized-keys-module/13346 "2013-08-21T19:16:24Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Michael\_Lucas](https://avatars.discourse-cdn.com/v4/letter/m/a183cd/32.png) [@Michael\_Lucas](https://forum.ansible.com/u/Michael_Lucas)\
**Post date:** [August 21, 2013, 7:16pm UTC](https://forum.ansible.com/t/bug-in-authorized-keys-module/13346/1 "2013-08-21T19:16:24Z")

</div>

Hi,

Wanted to verify that I'm not doing something dumb before opening a  
bug report. I pulled Ansible this morning.

Using the authorized\_keys module to copy keys to hosts, I lose the  
quote marks around the key restrictions. I have keys with limitations  
on them, such as:

from="192.0.2.5" ssh-rsa AAAAB3NzaC1...

When copied via authorized\_keys, it shows up as:

from=192.0.2.5 ssh-rsa AAAAB3NzaC1...

This keyfile is not usable for authentication, generating a the error:

Bad options in /etc/ssh/authorized\_keys/ansible file, line 1:

Should the authorized\_keys module do behave this way? Or am I probably  
doing something wrong?

Thanks,  
==ml

---

<div class="post-metadata">

**Author:** ![Brian\_Coca1](https://avatars.discourse-cdn.com/v4/letter/b/278dde/32.png) [@Brian\_Coca1](https://forum.ansible.com/u/Brian_Coca1)\
**Post date:** [August 21, 2013, 7:47pm UTC](https://forum.ansible.com/t/bug-in-authorized-keys-module/13346/2 "2013-08-21T19:47:09Z")

</div>

I don't think the current module is aware of from and command sections.

---

<div class="post-metadata">

**Author:** ![David\_Minor](https://avatars.discourse-cdn.com/v4/letter/d/b38774/32.png) [@David\_Minor](https://forum.ansible.com/u/David_Minor)\
**Post date:** [August 21, 2013, 9:25pm UTC](https://forum.ansible.com/t/bug-in-authorized-keys-module/13346/3 "2013-08-21T21:25:39Z")

</div>

The arguments after ‘authorized\_key:’ are tokenized by shlex, which is probably stripping out the quotes.

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan2](https://avatars.discourse-cdn.com/v4/letter/m/da6949/32.png) [@Michael\_DeHaan2](https://forum.ansible.com/u/Michael_DeHaan2)\
**Post date:** [August 22, 2013, 2:23am UTC](https://forum.ansible.com/t/bug-in-authorized-keys-module/13346/4 "2013-08-22T02:23:07Z")

</div>

Right, more of a feature request IMHO, but it would be nice to be able to support these.

I recall a pull request to support them but it wasn’t possibly ready because it included them as part of the key and maybe couldn’t modify them like you would expect.

---

<div class="post-metadata">

**Author:** ![Brian\_Coca1](https://avatars.discourse-cdn.com/v4/letter/b/278dde/32.png) [@Brian\_Coca1](https://forum.ansible.com/u/Brian_Coca1)\
**Post date:** [August 22, 2013, 2:27am UTC](https://forum.ansible.com/t/bug-in-authorized-keys-module/13346/5 "2013-08-22T02:27:30Z")

</div>

currently authorized\_keys treats the whole thing as a string and matches  
it, this breaks with from and command fields as you cannot use the same key  
more than once (only 1 instance will work), so this needs a bit more  
complex logic (separate into fields =\> match on key =\> update fields).

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan2](https://avatars.discourse-cdn.com/v4/letter/m/da6949/32.png) [@Michael\_DeHaan2](https://forum.ansible.com/u/Michael_DeHaan2)\
**Post date:** [August 22, 2013, 3:39am UTC](https://forum.ansible.com/t/bug-in-authorized-keys-module/13346/6 "2013-08-22T03:39:30Z")

</div>

Yes, I’d like it to take the from= and other fields as parameters.

---

<div class="post-metadata">

**Author:** ![Michael\_Lucas](https://avatars.discourse-cdn.com/v4/letter/m/a183cd/32.png) [@Michael\_Lucas](https://forum.ansible.com/u/Michael_Lucas)\
**Post date:** [August 22, 2013, 8:01pm UTC](https://forum.ansible.com/t/bug-in-authorized-keys-module/13346/7 "2013-08-22T20:01:57Z")

</div>

Hi,

Feature request logged as issue #3921. Mostly so other people who have  
this problem will find a mention of it.

For now, I'm going back to copying the key files.

==ml

---

<div class="post-metadata">

**Author:** ![Berend\_de\_Boer](https://avatars.discourse-cdn.com/v4/letter/b/e495f1/32.png) [@Berend\_de\_Boer](https://forum.ansible.com/u/Berend_de_Boer)\
**Post date:** [August 24, 2013, 2:15am UTC](https://forum.ansible.com/t/bug-in-authorized-keys-module/13346/8 "2013-08-24T02:15:46Z")

</div>

> Using the authorized\_keys module to copy keys to hosts, I lose the  
> quote marks around the key restrictions. I have keys with limitations  
> on them, such as:

Use ", that works for me.

All the best,

Berend.
