From d85199505c9ce77cd5824c7593a3ee4c8ed8a266 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hugo=20H=C3=B6rnquist?= Date: Wed, 29 Dec 2021 21:39:50 +0100 Subject: Automatic ssh keys. --- modules/ssh/manifests/init.pp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'modules') diff --git a/modules/ssh/manifests/init.pp b/modules/ssh/manifests/init.pp index 8db8eef..8a50ef1 100644 --- a/modules/ssh/manifests/init.pp +++ b/modules/ssh/manifests/init.pp @@ -1,5 +1,6 @@ class ssh ( Variant[Enum['prohibit-password'], Boolean] $permit_root_login = false, + Array[String] $authorized_keys = [], ) { $pkgs = $facts['os']['family'] ? { @@ -22,6 +23,20 @@ class ssh ( match => '^#? *PermitRootLogin ', } + file { '/root/.ssh': + ensure => directory, + } + + file { '/root/.ssh/authorized_keys': + ensure => file, + } + + $authorized_keys.each |$key| { + file_line { "Authorize ssh key ${key}": + path => '/root/.ssh/authorized_keys', + line => $key, + } + } # file { '/etc/ssh/sshd_config': # ensure => file, -- cgit v1.2.3