0

我正在尝试在应用 RDS Terraform 堆栈之前激活 ssh sock5 代理。

为此,我将 ssh 命令配置为 Terragrunt before_hook 块,示例如下:

  before_hook "ssh_tunnel_start" {
    commands = ["init", "plan", "apply"]
    execute  = ["ssh", "-D", "3306", "-M", "-S", "/tmp/ssh-control-socket", "-fnNTC", "<bastion_host>"]
  }

如果我在终端中手动执行 ssh 命令,它会按预期工作,ssh 绑定本地端口然后分离,但从 Terragrunt 挂钩执行,代理已启动,但 ssh 命令不分离并且 Terragrunt 进程无法继续并卡在钩子命令上。

4

1 回答 1

0

我通过使用屏幕找到了一个可行的解决方案,也许有更好的解决方案。

before_hook "ssh_tunnel_start" {
  commands = ["init", "plan", "apply"]
  execute  = ["screen", "-d", "-m", "ssh", "-D", "3306", "-M", "-S", "/tmp/ssh-control-socket", "-fnNTC", "<bastion_host>"      
}
于 2020-06-18T21:37:20.543 回答