From ed91f1eb64e83f6ac73e3b95f70df4474ff960e3 Mon Sep 17 00:00:00 2001 From: MiguelNdeCarvalho Date: Thu, 10 Oct 2024 18:53:08 +0000 Subject: [PATCH 1/4] variables.tf: Add ssh_log_to_stdout variable --- variables.tf | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/variables.tf b/variables.tf index 87b7b27..b48231c 100644 --- a/variables.tf +++ b/variables.tf @@ -57,6 +57,12 @@ variable "ssh_port" { description = "Specify the port that OpenSSH server will bind to. The port value can't be below 1024. If not defined it will use '2222' as default." } +variable "ssh_log_to_stdout" { + type = bool + default = false + description = "If set to true it will log the SSH connection to stdout." +} + variable "image_repository" { type = string default = "linuxserver/openssh-server" From b83a62c6534d9ba2766df51724b6123c79f9360e Mon Sep 17 00:00:00 2001 From: MiguelNdeCarvalho Date: Thu, 10 Oct 2024 18:53:49 +0000 Subject: [PATCH 2/4] README.md: Update docs --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index d34464b..097a96d 100644 --- a/README.md +++ b/README.md @@ -36,6 +36,7 @@ No modules. | [ssh\_host\_rsa\_key](#input\_ssh\_host\_rsa\_key) | Private key used by the OpenSSH server. If not defined it will generated automatically, but won't be saved. | `string` | `""` | no | | [ssh\_host\_rsa\_key\_public](#input\_ssh\_host\_rsa\_key\_public) | Public key used by the OpenSSH server. If not defined it will generated automatically, but won't be saved. | `string` | `""` | no | | [ssh\_keys](#input\_ssh\_keys) | List of SSH keys to be added to the authorized keys list. Should be in the same format as the 'authorized\_keys' file, represented in Heredoc style as a multi-line string value. | `string` | n/a | yes | +| [ssh\_log\_to\_stdout](#input\_ssh\_log\_to\_stdout) | If set to true it will log the SSH connection to stdout. | `bool` | `false` | no | | [ssh\_port](#input\_ssh\_port) | Specify the port that OpenSSH server will bind to. The port value can't be below 1024. If not defined it will use '2222' as default. | `number` | `2222` | no | | [ssh\_user](#input\_ssh\_user) | Specify a username to connect to. If not defined it will use 'user' as default. | `string` | `"user"` | no | | [sshd\_config](#input\_sshd\_config) | Configuration file for SSH. If not defined it will use the default. | `string` | `""` | no | From cd560a934e461976bdc8313c90ec0d9a132481c6 Mon Sep 17 00:00:00 2001 From: MiguelNdeCarvalho Date: Thu, 10 Oct 2024 18:58:41 +0000 Subject: [PATCH 3/4] main.tf: Add log to stdout docker mod --- main.tf | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/main.tf b/main.tf index da31ac6..726b710 100644 --- a/main.tf +++ b/main.tf @@ -9,9 +9,9 @@ resource "kubernetes_config_map" "main" { } data = { - "authorized_keys" = var.ssh_keys - "motd" = "Welcome to ${var.motd_name}.\n" - "delete-generated-ssh-keys" = < Date: Thu, 10 Oct 2024 19:05:14 +0000 Subject: [PATCH 4/4] main.tf: Add LOGS_TO_STDOUT env to log ssh to stdout --- main.tf | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/main.tf b/main.tf index 726b710..a138974 100644 --- a/main.tf +++ b/main.tf @@ -132,6 +132,14 @@ resource "kubernetes_deployment" "main" { value = "linuxserver/mods:openssh-server-ssh-tunnel${var.ssh_log_to_stdout ? "|linuxserver/mods:universal-stdout-logs" : ""}" } + dynamic "env" { + for_each = var.ssh_log_to_stdout ? ["dummy"] : [] + content { + name = "LOGS_TO_STDOUT" + value = "/config/logs/openssh/current" # OpenSSH logs + } + } + env { name = "PUBLIC_KEY_FILE" value = "/defaults/authorized_keys"