nu: Add tailscale ssh command

This commit is contained in:
2025-05-18 14:10:09 +02:00
parent 5fe3c435c5
commit 57198f0f77

View File

@ -1,8 +1,9 @@
# Get networking info about tailscale peers
def "tailscale peer" [ def "tailscale peer" [
hostname?: string hostname?: string
path?: cell-path get_field?: cell-path
]: nothing -> any { ]: 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) let status = (^tailscale status --json | from json)
@ -26,6 +27,14 @@ def "tailscale peer" [
if $hostname == null { if $hostname == null {
$peers $peers
} else { } 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
}