Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


  Search this Thread
Old 09-28-2016, 06:46 PM   #1
LQ Newbie
Registered: Jan 2014
Posts: 6

Rep: Reputation: Disabled
Using ansbile to deploy your ssh keys

Hello everyone,

I'm attempting to deploy my public ssh key ( from one server to two other servers. I'm using the the example here with the following configuration file called sshkeys.yml:

- name: Add Pub key
- hosts: server1,server2
- authorized_key: user=user1 key="{{ lookup('file', '/home/user1/.ssh/') }}"

The command I'm running is ansible-playbook sshkeys.yml -u user1 -k and the result I'm getting is this:

"ERROR! 'authorized_key' is not a valid attribute for a Play

The error appears to have been in '/home/user1/playbooks/sshkeys.yml': line 4, column 3, but may
be elsewhere in the file depending on the exact syntax problem.

The offending line appears to be:

- hosts: server1,server2
- authorized_key: user=user1 key="{{ lookup('file', '/home/user1/.ssh/') }}"
^ here
We could be wrong, but this one looks like it might be an issue with
missing quotes. Always quote template expression brackets when they
start a value. For instance:

- {{ foo }}

Should be written as:

- "{{ foo }}"

I'm copy the authorized_key value directly from ansible's documentation site. I have looked up at other examples but they don't vary from mine. Again, I'm just trying to deploy my public key from another server to two remote servers in the same subnet. Thanks in advance for your input.
Old 10-01-2016, 10:49 AM   #2
Senior Member
Registered: Jun 2005
Location: England
Distribution: openSUSE, Fedora, CentOS
Posts: 1,093

Rep: Reputation: 197Reputation: 197
Take a look at
Are the two of you in the same class or something?
Old 10-01-2016, 12:31 PM   #3
LQ Newbie
Registered: Jan 2012
Posts: 21

Rep: Reputation: Disabled
Arizonagroovejet, I posted the same question because I thought this didn't post. I will close this one as a duplicate. Do you have any input on the question?



Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
LXer: SSH login without password using SSH keys LXer Syndicated Linux News 0 09-21-2014 01:36 AM
software as a service? virtualization? ssh? how to deploy a new aplication jbcolmena Linux - Server 4 07-30-2010 01:51 PM
SSH host keys are not being read correctly from .ssh/known_hosts. bartonski Linux - Software 3 10-29-2009 04:40 PM
SSH host keys VS SSH keys kenneho Linux - Security 3 09-11-2008 06:03 AM
Configuring SSH to accept only keys (already have keys) fr0st Linux - Security 3 11-04-2003 03:31 AM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 07:26 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration