Appending keys to an authorized_keys file?

1,104 views
Skip to first unread message

Frédéric Médery

unread,
May 8, 2013, 9:20:12 AM5/8/13
to salt-...@googlegroups.com
Hey Guys,
I am having a hard time with this.
Based on the doc :
and this example : 
authorized_keys_srv:
  ssh_auth.present:
    - user: nagios
    - source:
      - salt://ssh/files/nag...@srv.pub

nag...@srv.pub contains 2 public keys.

From the doc : 
source: The source file for the key(s). Can contain any number of public keys, in standard "authorized_keys" format.
If this is set, comment, enc, and options will be ignored.

But on each attempt it only create the file with the latest pub key in the nag...@srv.pub

I try to avoid file.managed ATM simply because ssh_auth has been coded for that.
I also try with :

authorized_keys_srv1:
  ssh_auth.present:
    - user: nagios
    - source:
      - salt://ssh/files/nag...@srv1.pub
authorized_keys_srv2:
  ssh_auth.present:
    - user: nagios
    - source:
      - salt://ssh/files/nag...@srv2.pub

Same problem. The file only contains nag...@srv2.pub public key

Any idea ? 

tx

Mrten

unread,
May 8, 2013, 10:37:27 AM5/8/13
to salt-...@googlegroups.com
what happens if you do

- source: salt://ssh/files/nag...@srv2.pub

?

M.

frederi...@bloomdigital.com

unread,
May 8, 2013, 1:00:15 PM5/8/13
to salt-...@googlegroups.com
Hey tx for the answer.
with this :
authorized_keys_srv1:
  ssh_auth.present:
    - user: nagios
    - source: salt://ssh/files/nag...@srv1.pub
    - source: salt://ssh/files/nag...@srv2.pub

only appended srv2.pub

authorized_keys_srv1:
  ssh_auth.present:
    - user: nagios
    - source: 
       - salt://ssh/files/nag...@srv1.pub
       - salt://ssh/files/nag...@srv2.pub

Gave an error.
Base on the doc, source can contains multiple keys but for an unknown it does not work


On Wednesday, May 8, 2013 9:20:12 AM UTC-4, Frédéric Médery wrote:
Hey Guys,
I am having a hard time with this.
Based on the doc :
and this example : 
authorized_keys_srv:
  ssh_auth.present:
    - user: nagios
    - source:
      - salt://ssh/files/nagios@srv.pub

nag...@srv.pub contains 2 public keys.

From the doc : 
source: The source file for the key(s). Can contain any number of public keys, in standard "authorized_keys" format.
If this is set, comment, enc, and options will be ignored.

But on each attempt it only create the file with the latest pub key in the nag...@srv.pub

I try to avoid file.managed ATM simply because ssh_auth has been coded for that.
I also try with :

authorized_keys_srv1:
  ssh_auth.present:
    - user: nagios
    - source:
      - salt://ssh/files/nagios@srv1.pub
authorized_keys_srv2:
  ssh_auth.present:
    - user: nagios
    - source:
      - salt://ssh/files/nagios@srv2.pub

Same problem. The file only contains nag...@srv2.pub public key
 

Any idea ? 

tx

Mrten

unread,
May 8, 2013, 3:26:40 PM5/8/13
to salt-...@googlegroups.com
On 8/5/2013 19:00 , frederi...@bloomdigital.com wrote:

> Hey tx for the answer.
> with this :
> authorized_keys_srv1:
> ssh_auth.present:
> - user: nagios
> - source: salt://ssh/files/nag...@srv1.pub
> - source: salt://ssh/files/nag...@srv2.pub
>
> only appended srv2.pub
>
> authorized_keys_srv1:
> ssh_auth.present:
> - user: nagios
> - source:
> - salt://ssh/files/nag...@srv1.pub
> - salt://ssh/files/nag...@srv2.pub
>
> Gave an error.
> Base on the doc, source can contains multiple keys but for an unknown it
> does not work

i read that as "the file can contain multiple keys", not using multiple
source entries ;)

try putting both keys in the same file and reference that with source:.

M.

Frédéric Médery

unread,
May 9, 2013, 2:39:07 PM5/9/13
to salt-...@googlegroups.com
Tx for the help,
I found the problem. the keys inside the file were the same but with different comment. Salt code is smart enough to only parse the hash .
Problem solved
tx for all the responses.



Frédéric Médery

Adgear Technologies Inc.

(514)  394.7951 #235

http://www.adgear.com/




--
You received this message because you are subscribed to the Google Groups "Salt-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to salt-users+...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.



Anas Abojanah

unread,
Jun 19, 2016, 1:20:56 AM6/19/16
to Salt-users
Hi,

I have the same issue. How can I make Salt add the same key with different options to the authorized_keys file?

Anas 
Reply all
Reply to author
Forward
0 new messages