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

Add SSH support to ACLs #661

Closed
GrigoriyMikhalkin opened this issue Jun 23, 2022 · 11 comments
Closed

Add SSH support to ACLs #661

GrigoriyMikhalkin opened this issue Jun 23, 2022 · 11 comments
Labels
enhancement New feature or request

Comments

@GrigoriyMikhalkin
Copy link
Contributor

Feature request

Tailscale introduced Tailscale SSH feature, which allows to manage SSH connections as part of tailnet. In particular, user can control SSH access via ACLs. There's new field for that called ssh and here is an example of such config:

{
  "acls": [
    {
      "action": "accept",
      "src": ["*"],
      "dst": ["*:*"]
    }
  ],
  "ssh": [
    {
      "action": "accept",
      "src": ["autogroup:members"],
      "dst": ["autogroup:self"],
      "users": ["root", "autogroup:nonroot"]
    }
  ]
}

Would be great to see support for that in headscale. I would gladly try to help to implement this if this is ok.

@GrigoriyMikhalkin GrigoriyMikhalkin added the enhancement New feature or request label Jun 23, 2022
@juanfont
Copy link
Owner

Hi @GrigoriyMikhalkin, I am looking at it already - but want to merge some big stuff before.

But feel free to try :)

db48x added a commit to headlinevc/headscale that referenced this issue Jun 26, 2022
Advertises the SSH capability, and (incompletely) parses the SSH ACLs
to pass to the tailscale client. Doesn’t support most of the ACL
features yet, just very basic “accept” rules.

Will fix juanfont#661 once it is finished.
@db48x
Copy link
Contributor

db48x commented Jun 26, 2022

I started on implementing this, but have not yet had a chance to test it. It is at least good enough to let tailscale up --ssh work as long as there is an explicit ACL, so presumably tailscale ssh will work as well. I’ll see if I can make time to test it this coming week, and perhaps continue the work if nobody beats me to it.

@617a7aa
Copy link
Contributor

617a7aa commented Aug 17, 2022

@db48x @juanfont any updates on this? this is a pretty important setup step for us to use - happy to sponsor it if that means it gets added faster :)

@juanfont
Copy link
Owner

@617a7a I'll look into it as soon as we have the new protocol fully working

@kradalby kradalby added this to the v0.19.0 milestone Sep 8, 2022
@Thunderbottom
Copy link

@db48x tried the code from your fork, and I can't seem to get it to work even with ACLs explicitly specified, for example, my ACL configuration has:

{
	"groups": {
		"group:example": [
			"example"  // Namespace
		]
	},
	"hosts": {
		"client": "100.64.0.2"
	},
	"acls": [
		{
			"action": "accept",
			"src": ["*"],
			"dst": ["*:*"]
		}
	],
	"ssh": [
		{
			"action": "accept",
			"src": ["autogroup:members"],
			"dst": ["client"],
			"users": ["autogroup:nonroot"]
		}

	]
}

and when I try to connect to the client host with tailscale ssh, I get permission denied (tailscale). Is the current implementation lacking something? If it helps, the logs show me this:

2022-09-16T17:15:16+05:30 TRC ACL rules generated ACL=[{"DstPorts":[{"Bits":null,"IP":"*","Ports
":{"First":0,"Last":65535}}],"IPProto":[1,58,6,17],"SrcIPs":["*"]}]                             
2022-09-16T17:15:16+05:30 TRC SSH rules generated SSH=[{"action":{"accept":true,"allowLocalPortF
orwarding":true},"principals":[{"userLogin":"autogroup:members"}],"sshUsers":{"autogroup:nonroot
":"="}}] 

Let me know if there's anything else you need from me to make this work. Will be more than happy to be of help. Thanks a lot.

@restanrm
Copy link
Contributor

The autogroup feature is not supported yet, so I don't think you're ACL file can work at all.

@Thunderbottom
Copy link

Ah, was unaware, the acl docs link to the tailscale website. It even does not work with * as the src. Would it only work with a specified IP/group name?

@db48x
Copy link
Contributor

db48x commented Sep 17, 2022

Yes, my implementation is marked as a WIP for a reason. :)

My commit message probably should have been more explicit though; I got just far enough along to get tailscale to connect and no further. If you look at the relevant portion of my commit, you will see that I don’t handle wildcards or any form of group or tag. It will only work with explicit source and destination addresses, as well as explicit user names.

I’ve not yet been afforded any time to continue working on it, but if all goes well then I can sneak in some work on it this coming Friday. Really, the work to support tags and group names is not that difficult; any one of you could probably do it. You just have to look up the tag/group name in Headscale’s list of such and put the corresponding list of explicit addresses or user names into the SSHRules that get built.

@kradalby
Copy link
Collaborator

SSH support is now implemented as part of the Policy packaged during the codereorg.

@kradalby kradalby unpinned this issue Sep 24, 2023
@vbrandl
Copy link

vbrandl commented Sep 30, 2023

SSH support is now implemented as part of the Policy packaged during the codereorg.

Does this include autogroup?

@kradalby
Copy link
Collaborator

kradalby commented Oct 2, 2023

No, not yet, that is tracked separately in #657.

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

No branches or pull requests

8 participants