Update ssh.kt with all files
This commit is contained in:
parent
942b7ab3a9
commit
72ed2951ee
1 changed files with 24 additions and 2 deletions
|
@ -6,7 +6,9 @@ import org.domaindrivenarchitecture.provs.framework.ubuntu.filesystem.base.check
|
|||
import org.domaindrivenarchitecture.provs.framework.ubuntu.filesystem.base.createFileFromResource
|
||||
import org.domaindrivenarchitecture.provs.framework.ubuntu.install.base.isPackageInstalled
|
||||
|
||||
val pathSshConfig = "/etc/ssh/ssh_config"
|
||||
val pathSshdConfig = "/etc/ssh/sshd_config"
|
||||
val pathSshdHardeningConfig = "/etc/ssh/sshd_config.d/sshd_hardening.conf"
|
||||
val packageNameSshServer = "openssh-server"
|
||||
val resourcePathSsh = "org/domaindrivenarchitecture/provs/server/infrastructure/ssh/"
|
||||
|
||||
|
@ -14,14 +16,34 @@ fun Prov.isSshdConfigExisting(): Boolean {
|
|||
return checkFile(pathSshdConfig)
|
||||
}
|
||||
|
||||
fun Prov.configureSshd() = task {
|
||||
if(isSshdConfigExisting() && isPackageInstalled(packageNameSshServer)) {
|
||||
fun Prov.isSshConfigExisting(): Boolean {
|
||||
return checkFile(pathSshConfig)
|
||||
}
|
||||
|
||||
fun Prov.isSshdHardeningConfigExisting(): Boolean {
|
||||
return checkFile(pathSshdHardeningConfig)
|
||||
}
|
||||
|
||||
fun Prov.configureSsh() = task {
|
||||
if(isSshdConfigExisting() && isSshConfigExisting() && isSshdHardeningConfigExisting() && isPackageInstalled(packageNameSshServer)) {
|
||||
createFileFromResource(
|
||||
pathSshConfig,
|
||||
"ssh_config",
|
||||
resourcePathSsh,
|
||||
"644",
|
||||
true)
|
||||
createFileFromResource(
|
||||
pathSshdConfig,
|
||||
"sshd_config",
|
||||
resourcePathSsh,
|
||||
"644",
|
||||
true)
|
||||
createFileFromResource(
|
||||
pathSshdHardeningConfig,
|
||||
"sshd_hardening.conf",
|
||||
resourcePathSsh,
|
||||
"644",
|
||||
true)
|
||||
cmd("service ssh restart", sudo = true)
|
||||
} else {
|
||||
ProvResult(false)
|
||||
|
|
Loading…
Reference in a new issue