Featured image of post tailscaleのtagged deviceで詰まったら

tailscaleのtagged deviceで詰まったら

tailscale: failed to evaluate SSH policyConnection closed by <IP> port 22 の解決法

去年くらいからtailscaleを愛用しているのですが、最近自分のtailnetに人を入れることがあり、なんとかホストの管理をしないといけなくなってきていました。

そこであまり考えずにhostにtagをつけて管理しようとしていたのですが、その最中にいきなりsshができなくなってしまったのでその時の話を書こうと思います。

まず、むやみにtagをつけるのはやめましょう

ドキュメントを浅く読んで問題を引いたことのなんと多いことか…

# 発生した問題

とりあえずエラーログを出します。

1
2
3
4
5
6
7
$ ssh cotton@<HOST>
The authenticity of host '<HOST> (<IP>)' can't be established.
ED25519 key fingerprint is SHA256:<KEY>.
This key is not known by any other names.
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
Warning: Permanently added '<HOST>' (ED25519) to the list of known hosts.
tailscale: failed to evaluate SSH policyConnection closed by <IP> port 22`

???

failed to evaluate SSH policyConnectionとかいうエラーは今まで見たことがありませんでした。google検索でもあまりヒットせず…

# 解決法

どうやらtagをつけたtagged deviceはtagがついていないdeviceとは全然扱いが違うようです。なのでクライアントとサーバーに対してそれぞれtagをつけてアクセスできるようにすれば良いようです。

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
{
	"tagOwners": {
		"tag:tag1": ["autogroup:admin"],
		"tag:tag2": ["autogroup:admin"],
	},

	"acls": [
		{"action": "accept", "src": ["tag:tag1"], "dst": ["tag:tag2:*"]},
	],

	"ssh": [
		{
			"action": "accept",
			"src":    ["tag:tag1"],
			"dst":    ["tag:tag2"],
			"users":  ["autogroup:nonroot", "root"],
		},
		// tag1同士で接続したい場合
		{
			"action": "accept",
			"src":    ["tag:tag1"],
			"dst":    ["tag:tag1"],
			"users":  ["autogroup:nonroot", "root"],
		},
	],
}

こんな感じに接続元と接続先を書くことによって接続できるようになります。

# 問題の再現をしてみたかったけど…

色々やってみたのですが、同じエラーメッセージを引くことができませんでした…

# 原因

どうやら同じtagged deviceはtagged deviceにしかsshできないようです。つまり、tagged deviceからはtagが設定されていないuser-based identityのdeviceにはアクセスできないようです。

Devices with a tag-based identity can only SSH into other tagged devices; they cannot SSH into devices with a user-based identity.

# 参考

Licensed under CC BY-NC-SA 4.0
最終更新 Apr 15, 2025 00:00 UTC
comments powered by Disqus
Hugo で構築されています。
テーマ StackJimmy によって設計されています。