2021-12-21 14:56:24 +00:00
|
|
|
users_from_metadata = set()
|
|
|
|
additional_users = node.metadata.get('openssh/allowed_users', set())
|
|
|
|
|
|
|
|
for user, config in node.metadata.get('users', {}).items():
|
|
|
|
if 'ssh_pubkey' in config and not config.get('delete', False):
|
|
|
|
users_from_metadata.add(user)
|
|
|
|
|
|
|
|
login_users = users_from_metadata.union(additional_users)
|
|
|
|
|
|
|
|
files = {
|
|
|
|
'/etc/ssh/sshd_config': {
|
|
|
|
'content_type': 'mako',
|
|
|
|
'context': {
|
|
|
|
'login_users': login_users,
|
|
|
|
'admin_users': users_from_metadata,
|
|
|
|
'enable_x_forwarding_for_admins': node.metadata.get('openssh/enable_x_forwarding_for_admins', False),
|
|
|
|
},
|
|
|
|
'triggers': {
|
|
|
|
'action:sshd_check_config',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
'/etc/systemd/system/ssh.service.d/bundlewrap.conf': {
|
|
|
|
'source': 'override.conf',
|
|
|
|
'triggers': {
|
|
|
|
'action:sshd_check_config',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
2021-12-21 16:23:18 +00:00
|
|
|
pkg_apt = {
|
|
|
|
'openssh-client': {},
|
|
|
|
'openssh-server': {},
|
|
|
|
'openssh-sftp-server': {},
|
|
|
|
}
|
2021-12-21 14:56:24 +00:00
|
|
|
|
|
|
|
actions = {
|
|
|
|
'sshd_check_config': {
|
|
|
|
'command': 'sshd -T -C user=root -C host=localhost -C addr=localhost',
|
|
|
|
'triggered': True,
|
|
|
|
'triggers': {
|
2021-12-21 16:23:18 +00:00
|
|
|
'svc_systemd:sshd:restart',
|
2021-12-21 14:56:24 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
svc_systemd = {
|
2021-12-21 16:23:18 +00:00
|
|
|
'sshd': {
|
2021-12-21 14:56:24 +00:00
|
|
|
'needs': {
|
|
|
|
'file:/etc/systemd/system/ssh.service.d/bundlewrap.conf',
|
|
|
|
'file:/etc/ssh/sshd_config',
|
2021-12-21 16:23:18 +00:00
|
|
|
'pkg_apt:openssh-server',
|
2021-12-21 14:56:24 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|