Skip to content

Commit

Permalink
support multiple ssh keys
Browse files Browse the repository at this point in the history
  • Loading branch information
AaldertVanWijk-TomTom committed Oct 6, 2020
1 parent 640ce1f commit 36bc5e2
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,10 @@ resource "azurerm_virtual_machine" "vm-linux" {
disable_password_authentication = var.enable_ssh_key

dynamic ssh_keys {
for_each = var.enable_ssh_key ? [var.ssh_key] : []
for_each = var.enable_ssh_key ? var.ssh_keys : []
content {
path = "/home/${var.admin_username}/.ssh/authorized_keys"
key_data = file(var.ssh_key)
key_data = file(ssh_keys.value)
}
}
}
Expand Down
8 changes: 4 additions & 4 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ variable "admin_password" {
default = ""
}

variable "ssh_key" {
description = "Path to the public key to be used for ssh access to the VM. Only used with non-Windows vms and can be left as-is even if using Windows vms. If specifying a path to a certification on a Windows machine to provision a linux vm use the / in the path versus backslash. e.g. c:/home/id_rsa.pub."
type = string
default = "~/.ssh/id_rsa.pub"
variable "ssh_keys" {
description = "Paths to the public key files to be used for ssh access to the VM. Only used with non-Windows vms and can be left as-is even if using Windows vms. If specifying a path to a certification on a Windows machine to provision a linux vm use the / in the path versus backslash. e.g. c:/home/id_rsa.pub."
type = list(string)
default = ["~/.ssh/id_rsa.pub"]
}

variable "remote_port" {
Expand Down

0 comments on commit 36bc5e2

Please sign in to comment.