diff --git a/roles/hetzner_storagebox/templates/authorized_keys.j2 b/roles/hetzner_storagebox/templates/authorized_keys.j2
index 5ec3cb798731f159e638b7e2ee1730f665c394c5..45e8e4705fb219afc4f4843e2f771978e830c2f0 100644
--- a/roles/hetzner_storagebox/templates/authorized_keys.j2
+++ b/roles/hetzner_storagebox/templates/authorized_keys.j2
@@ -1,7 +1,7 @@
 #jinja2: lstrip_blocks: True
 # Arch DevOps keys
-{% for user in root_ssh_keys | sort -%}
-	{{ lookup('file', '../pubkeys/' + user) }}
+{% for user in root_ssh_keys | sort(attribute='key') -%}
+	{{ lookup('file', '../pubkeys/' + user.key) }}
 {% endfor %}
 
 # Client machines keys
diff --git a/roles/rsync_net/templates/authorized_keys.j2 b/roles/rsync_net/templates/authorized_keys.j2
index 5ec3cb798731f159e638b7e2ee1730f665c394c5..45e8e4705fb219afc4f4843e2f771978e830c2f0 100644
--- a/roles/rsync_net/templates/authorized_keys.j2
+++ b/roles/rsync_net/templates/authorized_keys.j2
@@ -1,7 +1,7 @@
 #jinja2: lstrip_blocks: True
 # Arch DevOps keys
-{% for user in root_ssh_keys | sort -%}
-	{{ lookup('file', '../pubkeys/' + user) }}
+{% for user in root_ssh_keys | sort(attribute='key') -%}
+	{{ lookup('file', '../pubkeys/' + user.key) }}
 {% endfor %}
 
 # Client machines keys