Fix duplicatded 'ssh-rsa' issue with template authorized_keys.erb

Even the input ssh_key has a string 'ssh-rsa', it would still generate
a new 'ssh-rsa' in authorized_keys with the template authorized_keys.erb
which would lead fail to authorize.

Change-Id: I851399ff30f611cc8fbae6651661b54117a4b8ae
This commit is contained in:
Yu Zhang 2017-11-03 14:03:35 +08:00
parent 7a9eafd698
commit dcb0568dfe
1 changed files with 12 additions and 4 deletions

View File

@ -1,10 +1,18 @@
# HEADER: This file has been autogenerated by puppet. # HEADER: This file has been autogenerated by puppet.
# HEADER: While it can still be managed manually, it # HEADER: While it can still be managed manually, it
# HEADER: is definitely not recommended. # HEADER: is definitely not recommended.
<% if @ssh_key.is_a? Array -%> <% if @ssh_key.is_a? Array %>
<% @ssh_key.each do |key| -%> <% @ssh_key.each do |key| %>
<% if key.include? 'ssh-rsa' %>
<%= key %>
<% else %>
ssh-rsa <%= key %> ssh-rsa <%= key %>
<% end -%> <% end %>
<% end %>
<% else %>
<% if @ssh_key.include? 'ssh-rsa' %>
<%= @ssh_key %>
<% else %> <% else %>
ssh-rsa <%= @ssh_key %> ssh-rsa <%= @ssh_key %>
<% end -%> <% end %>
<% end %>