diff --git a/cmd/tailscale/cli/cli_test.go b/cmd/tailscale/cli/cli_test.go index 48e0349de..5a495f9d5 100644 --- a/cmd/tailscale/cli/cli_test.go +++ b/cmd/tailscale/cli/cli_test.go @@ -1071,6 +1071,32 @@ func TestUpdatePrefs(t *testing.T) { }, env: upCheckEnv{backendState: "Running"}, }, + { + name: "force_reauth_over_ssh_no_risk", + flags: []string{"--force-reauth"}, + sshOverTailscale: true, + curPrefs: &ipn.Prefs{ + ControlURL: "https://login.tailscale.com", + AllowSingleHosts: true, + CorpDNS: true, + NetfilterMode: preftype.NetfilterOn, + }, + env: upCheckEnv{backendState: "Running"}, + wantErrSubtr: "aborted, no changes made", + }, + { + name: "force_reauth_over_ssh", + flags: []string{"--force-reauth", "--accept-risk=lose-ssh"}, + sshOverTailscale: true, + curPrefs: &ipn.Prefs{ + ControlURL: "https://login.tailscale.com", + AllowSingleHosts: true, + CorpDNS: true, + NetfilterMode: preftype.NetfilterOn, + }, + wantJustEditMP: nil, + env: upCheckEnv{backendState: "Running"}, + }, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { diff --git a/cmd/tailscale/cli/up.go b/cmd/tailscale/cli/up.go index a69064682..2e0b43e45 100644 --- a/cmd/tailscale/cli/up.go +++ b/cmd/tailscale/cli/up.go @@ -409,6 +409,12 @@ func updatePrefs(prefs, curPrefs *ipn.Prefs, env upCheckEnv) (simpleUp bool, jus return false, nil, err } + if env.upArgs.forceReauth && isSSHOverTailscale() { + if err := presentRiskToUser(riskLoseSSH, `You are connected over Tailscale; this action will result in your SSH session disconnecting.`, env.upArgs.acceptedRisks); err != nil { + return false, nil, err + } + } + tagsChanged := !reflect.DeepEqual(curPrefs.AdvertiseTags, prefs.AdvertiseTags) simpleUp = env.flagSet.NFlag() == 0 &&