-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.tf
More file actions
24 lines (20 loc) · 682 Bytes
/
Copy pathmain.tf
File metadata and controls
24 lines (20 loc) · 682 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
locals {
escaped_script_path = replace(var.script_path, "/", "\\/")
}
resource "ssh_resource" "keys" {
host = var.connection.host
user = var.connection.user
private_key = var.connection.private_key
agent = var.connection.agent
when = "create"
file {
source = "${path.module}/userkeys.sh"
destination = var.script_path
permissions = "0755"
}
commands = [
"sed -i -E 's/#?AuthorizedKeysCommand none/AuthorizedKeysCommand ${local.escaped_script_path} %u/' /etc/ssh/sshd_config",
"sed -i -E 's/#?AuthorizedKeysCommandUser nobody/AuthorizedKeysCommandUser nobody/' /etc/ssh/sshd_config",
"service ssh restart",
]
}