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

SSH Proxy Support #1709

Closed
phinze opened this issue Apr 28, 2015 · 22 comments
Closed

SSH Proxy Support #1709

phinze opened this issue Apr 28, 2015 · 22 comments
Assignees

Comments

@phinze
Copy link
Contributor

phinze commented Apr 28, 2015

I've been working on this already, but kicking off an issue so interested parties can track when it's done.

We'd like Terraform's remote-exec provisioner to support infrastructures with bastion hosts, which means we need SSH proxy support.

Go's crypto/ssh doesn't support openssh options, so we'll need to bake in our own proxy support along the lines of this example from the golang-nuts ML.

Tentative syntax for the feature:

resource "aws_instance" "public" {
  ami           = "${module.ami.ami_id}"
  instance_type = "${var.instance_type}"
  key_name      = "${var.key_name}"
  subnet_id     = "${element(split(",", module.vpc.public_subnets), count.index)}"

  vpc_security_group_ids = [
    "${aws_security_group.allow_internal_traffic.id}",
    "${aws_security_group.allow_ssh_from_world.id}",
  ]

  connection {
    user  = "ubuntu"
    agent = true
  }

  tags {
    Name = "public-instance"
  }
}


resource "aws_instance" "private" {
  ami           = "${module.ami.ami_id}"
  instance_type = "${var.instance_type}"
  key_name      = "${var.key_name}"
  subnet_id     = "${element(split(",", module.vpc.private_subnets), count.index)}"

  vpc_security_group_ids = [
    "${aws_security_group.allow_internal_traffic.id}",
  ]

  tags {
    Name = "private-instance"
  }


  /******************************
    vvv THIS WILL NOT WORK vvv
  *******************************/
  connection {
    user  = "ubuntu"
    agent = true
    proxy_hosts = [
      "ubuntu@${aws_instance.public.id}:22",
    ]
  }

  provisioner "remote-exec" {
    inline = "echo remote-exec works >> /tmp/remote-exec"
  }
  /******************************
    ^^^ LET'S MAKE IT WORK ^^^
  *******************************/
}
@radeksimko
Copy link
Member

FYI: CoreOS team has been solving the same issue: https://github.com/coreos/fleet/blob/19f0423fce91d6b50d6a4ab8b63f65970d83a5c5/ssh/ssh.go#L224-264

Another issue, which I'm surprised nobody brought here yet is SSH-agent (key forwarding), which makes me think that everyone just use ssh -i or nobody manages too many boxes to get annoyed about giant ~/.ssh/config 😃
It will become more important in these cases, when you probably don't want to see anyone uploading their private keys to the bastion host...

@phinze
Copy link
Contributor Author

phinze commented Apr 28, 2015

Cool thanks for that link! Will definitely take a look.

Re agent-forwarding: I didn't say it out loud, but I sort of consider agent-forwarding to be a required piece of this feature. Will update the title to reflect. 👌

@phinze phinze changed the title SSH Proxy Support SSH Proxy Support + Agent Forwarding Apr 28, 2015
@phinze
Copy link
Contributor Author

phinze commented Apr 28, 2015

Oh nevermind we already have an issue to track the agent forwarding side of things #1630

@phinze phinze changed the title SSH Proxy Support + Agent Forwarding SSH Proxy Support Apr 28, 2015
@radeksimko
Copy link
Member

Oh nevermind we already have an issue to track the agent forwarding side of things #1630

Ah, so it was just me being blind... 🙈

@progrium
Copy link

+1

@josharian
Copy link
Contributor

Possibly helpful: http://godoc.org/dev.justinjudd.org/justin/easyssh.

@phinze I recently spent a bit of time puzzling through some SSH server code while writing https://github.com/josharian/packer-provisioner-tunnel/, and this is something our team is excited about, so please let me know if I can help in any way.

@progrium
Copy link

progrium commented Jun 4, 2015

Glider Labs can implement this if somebody is willing to sponsor.

@nadnerb
Copy link

nadnerb commented Jun 5, 2015

+1

@pikeas
Copy link
Contributor

pikeas commented Jun 9, 2015

+1, this is a blocker for our use of Terraform.

@ketzacoatl
Copy link
Contributor

@pikeas, it seems like you could come up with a temporary workaround to start putting Terraform to use (you'll start reaping back rewards in saved time), while knowing you'll have a solution for the long-haul?

@mrwacky42
Copy link
Contributor

@phinze,
Perhaps it would be better to teach Go's crypto/ssh to interpret ssh config files, and not have to add new syntax to Terraform?

@svanharmelen
Copy link
Contributor

@mrwacky42 think you have a point...

@ketzacoatl
Copy link
Contributor

@mrwacky42 you really are onto something here.. in an instant.. you have made me realize how frustrating it is when tools either do not do this, or do not play nice with SSH at all.

++ to reading SSH configs, and for that to support specifing the path to the SSH config file to use.

@josharian
Copy link
Contributor

@hanwen thoughts?

@hanwen
Copy link

hanwen commented Jun 11, 2015

There is no need to change the ssh package. You can write your config parser as a separate package.

@gtmtech
Copy link

gtmtech commented Jun 15, 2015

+1 for the ssh proxy and options support. Without this, half of terraform is unfortunately unusable for me.

@markhuge
Copy link

+1

1 similar comment
@khoerling
Copy link

+1

@phinze
Copy link
Contributor Author

phinze commented Jun 22, 2015

This has hung out for some time while I percolated on the proper abstraction for config, and I ended up deciding that I'd rather get the basic functionality out to users in the forthcoming 0.6 release rather than wait for the perfect idea to strike.

I agree that extending crypto/ssh to parse SSH configs is probably better UX for this, but for now - let's just get it working! 😀

PR pushed over here #2425 - should make it in for 0.6.0. Feel free to take it for a spin!

And if any of you want to take a stab at SSH options support / config parsing - I'm sure both the Terraform and the Go communities would be excited to hear it. 👍

@phinze phinze closed this as completed Jun 22, 2015
@ketzacoatl
Copy link
Contributor

\o/

Will surely take this for a spin! Thanks @phinze for choosing to take action on what was simple and clear..

@chiefy
Copy link

chiefy commented Jun 27, 2015

thanks @phinze and team! can't wait to try this out.

@ghost
Copy link

ghost commented May 1, 2020

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@ghost ghost locked and limited conversation to collaborators May 1, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests