From 57198f0f771159f66eebb08aee610fa27468434f Mon Sep 17 00:00:00 2001 From: Joakim Hulthe Date: Sun, 18 May 2025 14:10:09 +0200 Subject: [PATCH] nu: Add `tailscale ssh` command --- tree/.local/nu/tailscale.nu | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/tree/.local/nu/tailscale.nu b/tree/.local/nu/tailscale.nu index a991fc7..79efc38 100644 --- a/tree/.local/nu/tailscale.nu +++ b/tree/.local/nu/tailscale.nu @@ -1,8 +1,9 @@ +# Get networking info about tailscale peers def "tailscale peer" [ hostname?: string - path?: cell-path + get_field?: cell-path ]: nothing -> any { - let path = ($path | default ([] | into cell-path)) + let get_field = ($get_field | default ([] | into cell-path)) let status = (^tailscale status --json | from json) @@ -26,6 +27,14 @@ def "tailscale peer" [ if $hostname == null { $peers } else { - $peers | where host == $hostname | first | get $path + $peers | where host == $hostname | first | get $get_field } } + +# SSH to a tailscale peer +def "tailscale ssh" [ + hostname?: string + ...ssh_flags: string +]: nothing -> any { + ssh -o $"HostName (tailscale peer $hostname | get ipv6)" $hostname ...$ssh_flags +}