Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Crashes on Debian/Ubuntu #47

Open
HanXHX opened this issue Oct 29, 2024 · 0 comments
Open

Crashes on Debian/Ubuntu #47

HanXHX opened this issue Oct 29, 2024 · 0 comments

Comments

@HanXHX
Copy link

HanXHX commented Oct 29, 2024

Hi,

I just checked your latest release (2.2.3). But I have a crashe, I don't understand why...

Some info:

$ lsb_release -av
No LSB modules are available.
Distributor ID:	Ubuntu
Description:	Ubuntu 22.04.3 LTS
Release:	22.04
Codename:	jammy
$ bash --version
GNU bash, version 5.1.16(1)-release (x86_64-pc-linux-gnu)
Copyright (C) 2020 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>

This is free software; you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
$ nohup --version
nohup (GNU coreutils) 8.32
Copyright (C) 2020 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <https://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

Written by Jim Meyering.
$ tofu --version
OpenTofu v1.6.1
on linux_amd64

My tofu code:

module db_tunnel {
  source       = "flaupretre/tunnel/ssh"
  version      = "2.2.3"

  target_host  = module.instance.instances[0].ip_v4
  target_port  = 3306

  gateway_host = var.ssh_bastion_host
}

provider "mysql" {
  endpoint = "${module.db_tunnel.host}:${module.db_tunnel.port}"
  username = "admin"
  password = "toto"
}

resource "mysql_database" "main" {
  name = "mydb"
}

I made minor changes on tunnel.sh (replace bash calls to bash -x). You can check in debug mode, the output:

Planning failed. OpenTofu encountered an error while generating this plan.

╷
│ Error: External Program Execution Failed
│ 
│   with module.db.module.db_tunnel.data.external.ssh_tunnel,
│   on .terraform/modules/db.db_tunnel/main.tf line 14, in data "external" "ssh_tunnel":
│   14:   program = [
│   15:     var.shell_cmd, "-x",
│   16:     "${path.module}/tunnel.sh"
│   17:   ]
│ 
│ The data source received an unexpected error while attempting to execute the program.
│ 
│ Program: /usr/bin/bash
│ Error Message: + TUNNEL_TF_PID=
│ + ret=0
│ + '[' -z '' ']'
│ + '[' -n '' ']'
│ +++ dirname .terraform/modules/db.db_tunnel/tunnel.sh
│ ++ cd .terraform/modules/db.db_tunnel
│ ++ pwd -P
│ + TUNNEL_ABSPATH=/home/myuser/dev/tofu/.terraform/modules/db.db_tunnel
│ + export TUNNEL_ABSPATH
│ ++ dd
│ +
│ query='{"create":"y","env":"","external_script":"undef","gateway_host":"my.bastion.tld","gateway_port":"22","gateway_user":"","gcloud_cmd":"gcloud","iap_project":"","iap_zone":"","kubectl_cmd":"kubectl","kubectl_context":"","kubectl_namespace":"","local_host":"127.0.0.1","local_port":"23727","parent_wait_sleep":"3","shell_cmd":"bash","ssh_cmd":"ssh
│ -o StrictHostKeyChecking=no -o
│ PasswordAuthentication=no","ssm_document_name":"AWS-StartSSHSession","ssm_options":"","ssm_profile":"","ssm_role":"","target_host":"10.10.0.104","target_port":"3306","timeout":"30m","tunnel_check_sleep":"0","type":"ssh"}'
│ + '[' -n '' ']'
│ ++ echo
│ '{"create":"y","env":"","external_script":"undef","gateway_host":"my.bastion.tld","gateway_port":"22","gateway_user":"","gcloud_cmd":"gcloud","iap_project":"","iap_zone":"","kubectl_cmd":"kubectl","kubectl_context":"","kubectl_namespace":"","local_host":"127.0.0.1","local_port":"23727","parent_wait_sleep":"3","shell_cmd":"bash","ssh_cmd":"ssh
│ -o StrictHostKeyChecking=no -o
│ PasswordAuthentication=no","ssm_document_name":"AWS-StartSSHSession","ssm_options":"","ssm_profile":"","ssm_role":"","target_host":"10.10.0.104","target_port":"3306","timeout":"30m","tunnel_check_sleep":"0","type":"ssh"}'
│ ++ sed -e 's/^.*\"create\": *\"//' -e 's/\",.*$//g' -e 's/\\\"/\"/g'
│ + TUNNEL_CREATE=y
│ + export TUNNEL_CREATE
│ ++ echo
│ '{"create":"y","env":"","external_script":"undef","gateway_host":"my.bastion.tld","gateway_port":"22","gateway_user":"","gcloud_cmd":"gcloud","iap_project":"","iap_zone":"","kubectl_cmd":"kubectl","kubectl_context":"","kubectl_namespace":"","local_host":"127.0.0.1","local_port":"23727","parent_wait_sleep":"3","shell_cmd":"bash","ssh_cmd":"ssh
│ -o StrictHostKeyChecking=no -o
│ PasswordAuthentication=no","ssm_document_name":"AWS-StartSSHSession","ssm_options":"","ssm_profile":"","ssm_role":"","target_host":"10.10.0.104","target_port":"3306","timeout":"30m","tunnel_check_sleep":"0","type":"ssh"}'
│ ++ sed -e 's/^.*\"type\": *\"//' -e 's/\".*$//g'
│ + TUNNEL_TYPE=ssh
│ + export TUNNEL_TYPE
│ ++ echo
│ '{"create":"y","env":"","external_script":"undef","gateway_host":"my.bastion.tld","gateway_port":"22","gateway_user":"","gcloud_cmd":"gcloud","iap_project":"","iap_zone":"","kubectl_cmd":"kubectl","kubectl_context":"","kubectl_namespace":"","local_host":"127.0.0.1","local_port":"23727","parent_wait_sleep":"3","shell_cmd":"bash","ssh_cmd":"ssh
│ -o StrictHostKeyChecking=no -o
│ PasswordAuthentication=no","ssm_document_name":"AWS-StartSSHSession","ssm_options":"","ssm_profile":"","ssm_role":"","target_host":"10.10.0.104","target_port":"3306","timeout":"30m","tunnel_check_sleep":"0","type":"ssh"}'
│ ++ sed -e 's/^.*\"env\": *\"//' -e 's/\",.*$//g' -e 's/\\\"/\"/g'
│ + TUNNEL_ENV=
│ + export TUNNEL_ENV
│ ++ echo
│ '{"create":"y","env":"","external_script":"undef","gateway_host":"my.bastion.tld","gateway_port":"22","gateway_user":"","gcloud_cmd":"gcloud","iap_project":"","iap_zone":"","kubectl_cmd":"kubectl","kubectl_context":"","kubectl_namespace":"","local_host":"127.0.0.1","local_port":"23727","parent_wait_sleep":"3","shell_cmd":"bash","ssh_cmd":"ssh
│ -o StrictHostKeyChecking=no -o
│ PasswordAuthentication=no","ssm_document_name":"AWS-StartSSHSession","ssm_options":"","ssm_profile":"","ssm_role":"","target_host":"10.10.0.104","target_port":"3306","timeout":"30m","tunnel_check_sleep":"0","type":"ssh"}'
│ ++ sed -e 's/^.*\"external_script\": *\"//' -e 's/\",.*$//g' -e 's/\\\"/\"/g'
│ + TUNNEL_EXTERNAL_SCRIPT=undef
│ + export TUNNEL_EXTERNAL_SCRIPT
│ ++ echo
│ '{"create":"y","env":"","external_script":"undef","gateway_host":"my.bastion.tld","gateway_port":"22","gateway_user":"","gcloud_cmd":"gcloud","iap_project":"","iap_zone":"","kubectl_cmd":"kubectl","kubectl_context":"","kubectl_namespace":"","local_host":"127.0.0.1","local_port":"23727","parent_wait_sleep":"3","shell_cmd":"bash","ssh_cmd":"ssh
│ -o StrictHostKeyChecking=no -o
│ PasswordAuthentication=no","ssm_document_name":"AWS-StartSSHSession","ssm_options":"","ssm_profile":"","ssm_role":"","target_host":"10.10.0.104","target_port":"3306","timeout":"30m","tunnel_check_sleep":"0","type":"ssh"}'
│ ++ sed -e 's/^.*\"gateway_host\": *\"//' -e 's/\".*$//g'
│ + TUNNEL_GATEWAY_HOST=my.bastion.tld
│ + export TUNNEL_GATEWAY_HOST
│ ++ echo
│ '{"create":"y","env":"","external_script":"undef","gateway_host":"my.bastion.tld","gateway_port":"22","gateway_user":"","gcloud_cmd":"gcloud","iap_project":"","iap_zone":"","kubectl_cmd":"kubectl","kubectl_context":"","kubectl_namespace":"","local_host":"127.0.0.1","local_port":"23727","parent_wait_sleep":"3","shell_cmd":"bash","ssh_cmd":"ssh
│ -o StrictHostKeyChecking=no -o
│ PasswordAuthentication=no","ssm_document_name":"AWS-StartSSHSession","ssm_options":"","ssm_profile":"","ssm_role":"","target_host":"10.10.0.104","target_port":"3306","timeout":"30m","tunnel_check_sleep":"0","type":"ssh"}'
│ ++ sed -e 's/^.*\"gateway_port\": *\"//' -e 's/\".*$//g'
│ + TUNNEL_GATEWAY_PORT=22
│ + export TUNNEL_GATEWAY_PORT
│ ++ echo
│ '{"create":"y","env":"","external_script":"undef","gateway_host":"my.bastion.tld","gateway_port":"22","gateway_user":"","gcloud_cmd":"gcloud","iap_project":"","iap_zone":"","kubectl_cmd":"kubectl","kubectl_context":"","kubectl_namespace":"","local_host":"127.0.0.1","local_port":"23727","parent_wait_sleep":"3","shell_cmd":"bash","ssh_cmd":"ssh
│ -o StrictHostKeyChecking=no -o
│ PasswordAuthentication=no","ssm_document_name":"AWS-StartSSHSession","ssm_options":"","ssm_profile":"","ssm_role":"","target_host":"10.10.0.104","target_port":"3306","timeout":"30m","tunnel_check_sleep":"0","type":"ssh"}'
│ ++ sed -e 's/^.*\"gateway_user\": *\"//' -e 's/\".*$//g'
│ + TUNNEL_GATEWAY_USER=
│ + export TUNNEL_GATEWAY_USER
│ ++ echo
│ '{"create":"y","env":"","external_script":"undef","gateway_host":"my.bastion.tld","gateway_port":"22","gateway_user":"","gcloud_cmd":"gcloud","iap_project":"","iap_zone":"","kubectl_cmd":"kubectl","kubectl_context":"","kubectl_namespace":"","local_host":"127.0.0.1","local_port":"23727","parent_wait_sleep":"3","shell_cmd":"bash","ssh_cmd":"ssh
│ -o StrictHostKeyChecking=no -o
│ PasswordAuthentication=no","ssm_document_name":"AWS-StartSSHSession","ssm_options":"","ssm_profile":"","ssm_role":"","target_host":"10.10.0.104","target_port":"3306","timeout":"30m","tunnel_check_sleep":"0","type":"ssh"}'
│ ++ sed -e 's/^.*\"iap_project\": *\"//' -e 's/\",.*$//g' -e 's/\\\"/\"/g'
│ + TUNNEL_IAP_GCP_PROJECT=
│ + export TUNNEL_IAP_PROJECT
│ ++ echo
│ '{"create":"y","env":"","external_script":"undef","gateway_host":"my.bastion.tld","gateway_port":"22","gateway_user":"","gcloud_cmd":"gcloud","iap_project":"","iap_zone":"","kubectl_cmd":"kubectl","kubectl_context":"","kubectl_namespace":"","local_host":"127.0.0.1","local_port":"23727","parent_wait_sleep":"3","shell_cmd":"bash","ssh_cmd":"ssh
│ -o StrictHostKeyChecking=no -o
│ PasswordAuthentication=no","ssm_document_name":"AWS-StartSSHSession","ssm_options":"","ssm_profile":"","ssm_role":"","target_host":"10.10.0.104","target_port":"3306","timeout":"30m","tunnel_check_sleep":"0","type":"ssh"}'
│ ++ sed -e 's/^.*\"iap_zone\": *\"//' -e 's/\",.*$//g' -e 's/\\\"/\"/g'
│ + TUNNEL_IAP_GCP_ZONE=
│ + export TUNNEL_IAP_ZONE
│ ++ echo
│ '{"create":"y","env":"","external_script":"undef","gateway_host":"my.bastion.tld","gateway_port":"22","gateway_user":"","gcloud_cmd":"gcloud","iap_project":"","iap_zone":"","kubectl_cmd":"kubectl","kubectl_context":"","kubectl_namespace":"","local_host":"127.0.0.1","local_port":"23727","parent_wait_sleep":"3","shell_cmd":"bash","ssh_cmd":"ssh
│ -o StrictHostKeyChecking=no -o
│ PasswordAuthentication=no","ssm_document_name":"AWS-StartSSHSession","ssm_options":"","ssm_profile":"","ssm_role":"","target_host":"10.10.0.104","target_port":"3306","timeout":"30m","tunnel_check_sleep":"0","type":"ssh"}'
│ ++ sed -e 's/^.*\"gcloud_cmd\": *\"//' -e 's/\",.*$//g' -e 's/\\\"/\"/g'
│ + TUNNEL_GCLOUD_CMD=gcloud
│ + export TUNNEL_GCLOUD_CMD
│ ++ echo
│ '{"create":"y","env":"","external_script":"undef","gateway_host":"my.bastion.tld","gateway_port":"22","gateway_user":"","gcloud_cmd":"gcloud","iap_project":"","iap_zone":"","kubectl_cmd":"kubectl","kubectl_context":"","kubectl_namespace":"","local_host":"127.0.0.1","local_port":"23727","parent_wait_sleep":"3","shell_cmd":"bash","ssh_cmd":"ssh
│ -o StrictHostKeyChecking=no -o
│ PasswordAuthentication=no","ssm_document_name":"AWS-StartSSHSession","ssm_options":"","ssm_profile":"","ssm_role":"","target_host":"10.10.0.104","target_port":"3306","timeout":"30m","tunnel_check_sleep":"0","type":"ssh"}'
│ ++ sed -e 's/^.*\"kubectl_cmd\": *\"//' -e 's/\",.*$//g' -e 's/\\\"/\"/g'
│ + TUNNEL_KUBECTL_CMD=kubectl
│ + export TUNNEL_KUBECTL_CMD
│ ++ echo
│ '{"create":"y","env":"","external_script":"undef","gateway_host":"my.bastion.tld","gateway_port":"22","gateway_user":"","gcloud_cmd":"gcloud","iap_project":"","iap_zone":"","kubectl_cmd":"kubectl","kubectl_context":"","kubectl_namespace":"","local_host":"127.0.0.1","local_port":"23727","parent_wait_sleep":"3","shell_cmd":"bash","ssh_cmd":"ssh
│ -o StrictHostKeyChecking=no -o
│ PasswordAuthentication=no","ssm_document_name":"AWS-StartSSHSession","ssm_options":"","ssm_profile":"","ssm_role":"","target_host":"10.10.0.104","target_port":"3306","timeout":"30m","tunnel_check_sleep":"0","type":"ssh"}'
│ ++ sed -e 's/^.*\"kubectl_context\": *\"//' -e 's/\",.*$//g' -e 's/\\\"/\"/g'
│ + TUNNEL_KUBECTL_CONTEXT=
│ + export TUNNEL_KUBECTL_CONTEXT
│ ++ echo
│ '{"create":"y","env":"","external_script":"undef","gateway_host":"my.bastion.tld","gateway_port":"22","gateway_user":"","gcloud_cmd":"gcloud","iap_project":"","iap_zone":"","kubectl_cmd":"kubectl","kubectl_context":"","kubectl_namespace":"","local_host":"127.0.0.1","local_port":"23727","parent_wait_sleep":"3","shell_cmd":"bash","ssh_cmd":"ssh
│ -o StrictHostKeyChecking=no -o
│ PasswordAuthentication=no","ssm_document_name":"AWS-StartSSHSession","ssm_options":"","ssm_profile":"","ssm_role":"","target_host":"10.10.0.104","target_port":"3306","timeout":"30m","tunnel_check_sleep":"0","type":"ssh"}'
│ ++ sed -e 's/^.*\"kubectl_namespace\": *\"//' -e 's/\",.*$//g' -e 's/\\\"/\"/g'
│ + TUNNEL_KUBECTL_NAMESPACE=
│ + export TUNNEL_KUBECTL_NAMESPACE
│ ++ echo
│ '{"create":"y","env":"","external_script":"undef","gateway_host":"my.bastion.tld","gateway_port":"22","gateway_user":"","gcloud_cmd":"gcloud","iap_project":"","iap_zone":"","kubectl_cmd":"kubectl","kubectl_context":"","kubectl_namespace":"","local_host":"127.0.0.1","local_port":"23727","parent_wait_sleep":"3","shell_cmd":"bash","ssh_cmd":"ssh
│ -o StrictHostKeyChecking=no -o
│ PasswordAuthentication=no","ssm_document_name":"AWS-StartSSHSession","ssm_options":"","ssm_profile":"","ssm_role":"","target_host":"10.10.0.104","target_port":"3306","timeout":"30m","tunnel_check_sleep":"0","type":"ssh"}'
│ ++ sed -e 's/^.*\"local_host\": *\"//' -e 's/\".*$//g'
│ + TUNNEL_LOCAL_HOST=127.0.0.1
│ + export TUNNEL_LOCAL_HOST
│ ++ echo
│ '{"create":"y","env":"","external_script":"undef","gateway_host":"my.bastion.tld","gateway_port":"22","gateway_user":"","gcloud_cmd":"gcloud","iap_project":"","iap_zone":"","kubectl_cmd":"kubectl","kubectl_context":"","kubectl_namespace":"","local_host":"127.0.0.1","local_port":"23727","parent_wait_sleep":"3","shell_cmd":"bash","ssh_cmd":"ssh
│ -o StrictHostKeyChecking=no -o
│ PasswordAuthentication=no","ssm_document_name":"AWS-StartSSHSession","ssm_options":"","ssm_profile":"","ssm_role":"","target_host":"10.10.0.104","target_port":"3306","timeout":"30m","tunnel_check_sleep":"0","type":"ssh"}'
│ ++ sed -e 's/^.*\"local_port\": *\"//' -e 's/\".*$//g'
│ + TUNNEL_LOCAL_PORT=23727
│ + export TUNNEL_LOCAL_PORT
│ ++ echo
│ '{"create":"y","env":"","external_script":"undef","gateway_host":"my.bastion.tld","gateway_port":"22","gateway_user":"","gcloud_cmd":"gcloud","iap_project":"","iap_zone":"","kubectl_cmd":"kubectl","kubectl_context":"","kubectl_namespace":"","local_host":"127.0.0.1","local_port":"23727","parent_wait_sleep":"3","shell_cmd":"bash","ssh_cmd":"ssh
│ -o StrictHostKeyChecking=no -o
│ PasswordAuthentication=no","ssm_document_name":"AWS-StartSSHSession","ssm_options":"","ssm_profile":"","ssm_role":"","target_host":"10.10.0.104","target_port":"3306","timeout":"30m","tunnel_check_sleep":"0","type":"ssh"}'
│ ++ sed -e 's/^.*\"parent_wait_sleep\": *\"//' -e 's/\",.*$//g' -e 's/\\\"/\"/g'
│ + TUNNEL_PARENT_WAIT_SLEEP=3
│ + export TUNNEL_PARENT_WAIT_SLEEP
│ ++ echo
│ '{"create":"y","env":"","external_script":"undef","gateway_host":"my.bastion.tld","gateway_port":"22","gateway_user":"","gcloud_cmd":"gcloud","iap_project":"","iap_zone":"","kubectl_cmd":"kubectl","kubectl_context":"","kubectl_namespace":"","local_host":"127.0.0.1","local_port":"23727","parent_wait_sleep":"3","shell_cmd":"bash","ssh_cmd":"ssh
│ -o StrictHostKeyChecking=no -o
│ PasswordAuthentication=no","ssm_document_name":"AWS-StartSSHSession","ssm_options":"","ssm_profile":"","ssm_role":"","target_host":"10.10.0.104","target_port":"3306","timeout":"30m","tunnel_check_sleep":"0","type":"ssh"}'
│ ++ sed -e 's/^.*\"shell_cmd\": *\"//' -e 's/\",.*$//g' -e 's/\\\"/\"/g'
│ + TUNNEL_SHELL_CMD=bash
│ + export TUNNEL_SHELL_CMD
│ ++ echo
│ '{"create":"y","env":"","external_script":"undef","gateway_host":"my.bastion.tld","gateway_port":"22","gateway_user":"","gcloud_cmd":"gcloud","iap_project":"","iap_zone":"","kubectl_cmd":"kubectl","kubectl_context":"","kubectl_namespace":"","local_host":"127.0.0.1","local_port":"23727","parent_wait_sleep":"3","shell_cmd":"bash","ssh_cmd":"ssh
│ -o StrictHostKeyChecking=no -o
│ PasswordAuthentication=no","ssm_document_name":"AWS-StartSSHSession","ssm_options":"","ssm_profile":"","ssm_role":"","target_host":"10.10.0.104","target_port":"3306","timeout":"30m","tunnel_check_sleep":"0","type":"ssh"}'
│ ++ sed -e 's/^.*\"ssh_cmd\": *\"//' -e 's/\",.*$//g' -e 's/\\\"/\"/g'
│ + TUNNEL_SSH_CMD='ssh -o StrictHostKeyChecking=no -o PasswordAuthentication=no'
│ + export TUNNEL_SSH_CMD
│ ++ echo
│ '{"create":"y","env":"","external_script":"undef","gateway_host":"my.bastion.tld","gateway_port":"22","gateway_user":"","gcloud_cmd":"gcloud","iap_project":"","iap_zone":"","kubectl_cmd":"kubectl","kubectl_context":"","kubectl_namespace":"","local_host":"127.0.0.1","local_port":"23727","parent_wait_sleep":"3","shell_cmd":"bash","ssh_cmd":"ssh
│ -o StrictHostKeyChecking=no -o
│ PasswordAuthentication=no","ssm_document_name":"AWS-StartSSHSession","ssm_options":"","ssm_profile":"","ssm_role":"","target_host":"10.10.0.104","target_port":"3306","timeout":"30m","tunnel_check_sleep":"0","type":"ssh"}'
│ ++ sed -e 's/^.*\"ssm_document_name\": *\"//' -e 's/\",.*$//g' -e 's/\\\"/\"/g'
│ + TUNNEL_SSM_DOCUMENT_NAME=AWS-StartSSHSession
│ + export TUNNEL_SSM_DOCUMENT_NAME
│ ++ echo
│ '{"create":"y","env":"","external_script":"undef","gateway_host":"my.bastion.tld","gateway_port":"22","gateway_user":"","gcloud_cmd":"gcloud","iap_project":"","iap_zone":"","kubectl_cmd":"kubectl","kubectl_context":"","kubectl_namespace":"","local_host":"127.0.0.1","local_port":"23727","parent_wait_sleep":"3","shell_cmd":"bash","ssh_cmd":"ssh
│ -o StrictHostKeyChecking=no -o
│ PasswordAuthentication=no","ssm_document_name":"AWS-StartSSHSession","ssm_options":"","ssm_profile":"","ssm_role":"","target_host":"10.10.0.104","target_port":"3306","timeout":"30m","tunnel_check_sleep":"0","type":"ssh"}'
│ ++ sed -e 's/^.*\"ssm_options\": *\"//' -e 's/\",.*$//g' -e 's/\\\"/\"/g'
│ + TUNNEL_SSM_OPTIONS=
│ + export TUNNEL_SSM_OPTIONS
│ ++ echo
│ '{"create":"y","env":"","external_script":"undef","gateway_host":"my.bastion.tld","gateway_port":"22","gateway_user":"","gcloud_cmd":"gcloud","iap_project":"","iap_zone":"","kubectl_cmd":"kubectl","kubectl_context":"","kubectl_namespace":"","local_host":"127.0.0.1","local_port":"23727","parent_wait_sleep":"3","shell_cmd":"bash","ssh_cmd":"ssh
│ -o StrictHostKeyChecking=no -o
│ PasswordAuthentication=no","ssm_document_name":"AWS-StartSSHSession","ssm_options":"","ssm_profile":"","ssm_role":"","target_host":"10.10.0.104","target_port":"3306","timeout":"30m","tunnel_check_sleep":"0","type":"ssh"}'
│ ++ sed -e 's/^.*\"target_host\": *\"//' -e 's/\".*$//g'
│ + TUNNEL_TARGET_HOST=10.10.0.104
│ + export TUNNEL_TARGET_HOST
│ ++ echo
│ '{"create":"y","env":"","external_script":"undef","gateway_host":"my.bastion.tld","gateway_port":"22","gateway_user":"","gcloud_cmd":"gcloud","iap_project":"","iap_zone":"","kubectl_cmd":"kubectl","kubectl_context":"","kubectl_namespace":"","local_host":"127.0.0.1","local_port":"23727","parent_wait_sleep":"3","shell_cmd":"bash","ssh_cmd":"ssh
│ -o StrictHostKeyChecking=no -o
│ PasswordAuthentication=no","ssm_document_name":"AWS-StartSSHSession","ssm_options":"","ssm_profile":"","ssm_role":"","target_host":"10.10.0.104","target_port":"3306","timeout":"30m","tunnel_check_sleep":"0","type":"ssh"}'
│ ++ sed -e 's/^.*\"target_port\": *\"//' -e 's/\".*$//g'
│ + TUNNEL_TARGET_PORT=3306
│ + export TUNNEL_TARGET_PORT
│ ++ echo
│ '{"create":"y","env":"","external_script":"undef","gateway_host":"my.bastion.tld","gateway_port":"22","gateway_user":"","gcloud_cmd":"gcloud","iap_project":"","iap_zone":"","kubectl_cmd":"kubectl","kubectl_context":"","kubectl_namespace":"","local_host":"127.0.0.1","local_port":"23727","parent_wait_sleep":"3","shell_cmd":"bash","ssh_cmd":"ssh
│ -o StrictHostKeyChecking=no -o
│ PasswordAuthentication=no","ssm_document_name":"AWS-StartSSHSession","ssm_options":"","ssm_profile":"","ssm_role":"","target_host":"10.10.0.104","target_port":"3306","timeout":"30m","tunnel_check_sleep":"0","type":"ssh"}'
│ ++ sed -e 's/^.*\"timeout\": *\"//' -e 's/\".*$//g'
│ + TUNNEL_TIMEOUT=30m
│ + export TUNNEL_TIMEOUT
│ ++ echo
│ '{"create":"y","env":"","external_script":"undef","gateway_host":"my.bastion.tld","gateway_port":"22","gateway_user":"","gcloud_cmd":"gcloud","iap_project":"","iap_zone":"","kubectl_cmd":"kubectl","kubectl_context":"","kubectl_namespace":"","local_host":"127.0.0.1","local_port":"23727","parent_wait_sleep":"3","shell_cmd":"bash","ssh_cmd":"ssh
│ -o StrictHostKeyChecking=no -o
│ PasswordAuthentication=no","ssm_document_name":"AWS-StartSSHSession","ssm_options":"","ssm_profile":"","ssm_role":"","target_host":"10.10.0.104","target_port":"3306","timeout":"30m","tunnel_check_sleep":"0","type":"ssh"}'
│ ++ sed -e 's/^.*\"tunnel_check_sleep\": *\"//' -e 's/\",.*$//g' -e 's/\\\"/\"/g'
│ + TUNNEL_CHECK_SLEEP=0
│ + export TUNNEL_CHECK_SLEEP
│ ++ echo
│ '{"create":"y","env":"","external_script":"undef","gateway_host":"my.bastion.tld","gateway_port":"22","gateway_user":"","gcloud_cmd":"gcloud","iap_project":"","iap_zone":"","kubectl_cmd":"kubectl","kubectl_context":"","kubectl_namespace":"","local_host":"127.0.0.1","local_port":"23727","parent_wait_sleep":"3","shell_cmd":"bash","ssh_cmd":"ssh
│ -o StrictHostKeyChecking=no -o
│ PasswordAuthentication=no","ssm_document_name":"AWS-StartSSHSession","ssm_options":"","ssm_profile":"","ssm_role":"","target_host":"10.10.0.104","target_port":"3306","timeout":"30m","tunnel_check_sleep":"0","type":"ssh"}'
│ ++ sed -e 's/^.*\"ssm_profile\": *\"//' -e 's/\",.*$//g' -e 's/\\\"/\"/g'
│ + TUNNEL_SSM_PROFILE=
│ + export TUNNEL_SSM_PROFILE
│ ++ echo
│ '{"create":"y","env":"","external_script":"undef","gateway_host":"my.bastion.tld","gateway_port":"22","gateway_user":"","gcloud_cmd":"gcloud","iap_project":"","iap_zone":"","kubectl_cmd":"kubectl","kubectl_context":"","kubectl_namespace":"","local_host":"127.0.0.1","local_port":"23727","parent_wait_sleep":"3","shell_cmd":"bash","ssh_cmd":"ssh
│ -o StrictHostKeyChecking=no -o
│ PasswordAuthentication=no","ssm_document_name":"AWS-StartSSHSession","ssm_options":"","ssm_profile":"","ssm_role":"","target_host":"10.10.0.104","target_port":"3306","timeout":"30m","tunnel_check_sleep":"0","type":"ssh"}'
│ ++ sed -e 's/^.*\"ssm_role\": *\"//' -e 's/\",.*$//g' -e 's/\\\"/\"/g'
│ + TUNNEL_SSM_ROLE=
│ + export TUNNEL_SSM_ROLE
│ + '[' Xy = X -o Xmy.bastion.tld = X ']'
│ + do_tunnel=y
│ + cnx_host=127.0.0.1
│ + cnx_port=23727
│ + echo '{ "host": "127.0.0.1",  "port": "23727" }'
│ + '[' -n y ']'
│ + ps_is_busybox
│ + test -h /bin/ps
│ + return 1
│ ++ ps p 19539 -o ppid=
│ ++ sed 's/ //g'
│ + p=19265
│ ++ mktemp
│ + clog=/tmp/tmp.Q5xtUDTxYZ
│ + TUNNEL_CHILD_PID=19746
│ + sleep 3
│ + nohup timeout 30m bash -x /home/myuser/dev/tofu/.terraform/modules/db.db_tunnel/tunnel.sh 19265
│ + process_is_up 19746
│ + local pid ret
│ + pid=19746
│ + ps_is_busybox
│ + test -h /bin/ps
│ + return 1
│ + ps -p 19746
│ + ret=1
│ + return 1
│ + echo 'Child process (19746) failure - Aborting'
│ Child process (19746) failure - Aborting
│ + echo 'Child diagnostics follow:'
│ Child diagnostics follow:
│ + cat /tmp/tmp.Q5xtUDTxYZ
│ + TUNNEL_TF_PID=19265
│ + ret=0
│ + '[' -z 19265 ']'
│ + '[' -n '' ']'
│ + TUNNEL_PID=
│ + TUNNEL_TODELETE=
│ + script=/home/myuser/dev/tofu/.terraform/modules/db.db_tunnel/gateways/ssh.sh
│ + '[' '!' -f /home/myuser/dev/tofu/.terraform/modules/db.db_tunnel/gateways/ssh.sh ']'
│ + '[' -n '' ']'
│ + . /home/myuser/dev/tofu/.terraform/modules/db.db_tunnel/gateways/ssh.sh
│ ++ gw=my.bastion.tld
│ ++ '[' X = X ']'
│ ++ TUNNEL_PID=19749
│ + sleep 0
│ ++ ssh -o StrictHostKeyChecking=no -o PasswordAuthentication=no -N -L 127.0.0.1:23727:10.10.0.104:3306 -p 22 my.bastion.tld
│ + true
│ + process_is_up 19749
│ + local pid ret
│ + pid=19749
│ + ps_is_busybox
│ + test -h /bin/ps
│ + return 1
│ + ps -p 19749
│ + ret=0
│ + return 0
│ + process_is_up 19265
│ + local pid ret
│ + pid=19265
│ + ps_is_busybox
│ + test -h /bin/ps
│ + return 1
│ + ps -p 19265
│ + ret=0
│ + return 0
│ + sleep 1
│ + true
│ + process_is_up 19749
│ + local pid ret
│ + pid=19749
│ + ps_is_busybox
│ + test -h /bin/ps
│ + return 1
│ + ps -p 19749
│ + ret=1
│ + return 1
│ + echo 'SSH process (19749) failure - Aborting'
│ SSH process (19749) failure - Aborting
│ + '[' -n '' ']'
│ + exit 1
│ + rm -f /tmp/tmp.Q5xtUDTxYZ
│ + ret=1
│ + exit 1
│ 
│ State: exit status 1
╵

The SSH command ssh -o StrictHostKeyChecking=no -o PasswordAuthentication=no -N -L 127.0.0.1:23727:10.10.0.104:3306 -p 22 my.bastion.tld works fine.

Any idea?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant