Skip to content

Commit 15a4894

Browse files
committed
P:puppet::server: Restrict source addresses for puppet-sync keys
1 parent 02c0729 commit 15a4894

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

modules/profile/manifests/puppet/server.pp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@
265265
user => 'root',
266266
type => $key.split(' ')[0],
267267
key => $key.split(' ')[1],
268-
options => ['restrict'],
268+
options => ['restrict', ssh::client::from_restriction()],
269269
tag => 'profile::puppet::server::puppet_sync',
270270
}
271271
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# @summary constructs a ssh authorized_keys from= restriction
2+
# for connections from this machine.
3+
function ssh::client::from_restriction () >> String[1] {
4+
$ips = [$facts['networking']['ip'], $facts['networking']['ip6']].filter |$x| {
5+
# check if we have a routable IPv6 address (and not just a link-local one)
6+
$x =~ NotUndef and !($x =~ /^fe80/)
7+
}.sort
8+
9+
"from=\"${ips.join(',')}\""
10+
}

0 commit comments

Comments
 (0)