-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathssh.tf
More file actions
24 lines (21 loc) · 730 Bytes
/
ssh.tf
File metadata and controls
24 lines (21 loc) · 730 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
# Generate an ED25519 SSH key pair
resource "tls_private_key" "ssh_key" {
algorithm = "ED25519"
}
# Write the private key to local disk
resource "local_file" "ssh_key" {
content = tls_private_key.ssh_key.private_key_openssh
file_permission = "0600"
filename = "${path.module}/id_rsa"
}
# Not really needed but lets write the public key too
resource "local_file" "ssh_key_pub" {
content = tls_private_key.ssh_key.public_key_openssh
file_permission = "0640"
filename = "${path.module}/id_rsa.pub"
}
# Create the ssh key in openstack
resource "openstack_compute_keypair_v2" "ssh-key" {
name = "${local.prefix}-sshkey"
public_key = tls_private_key.ssh_key.public_key_openssh
}