From 95210d542e4ee257b1e4585391a791b5ca905ea2 Mon Sep 17 00:00:00 2001 From: Lonny Wong Date: Sat, 30 Nov 2024 09:23:58 +0800 Subject: [PATCH] support token %k #158 --- tssh/tokens.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tssh/tokens.go b/tssh/tokens.go index 2fbeb58..8591864 100644 --- a/tssh/tokens.go +++ b/tssh/tokens.go @@ -130,6 +130,12 @@ func expandTokens(str string, args *sshArgs, param *sshParam, tokens string) (st hashStr += param.proxy[len(param.proxy)-1] } buf.WriteString(fmt.Sprintf("%x", sha1.Sum([]byte(hashStr)))) + case 'k': + if hostKeyAlias := getOptionConfig(args, "HostKeyAlias"); hostKeyAlias != "" { + buf.WriteString(hostKeyAlias) + } else { + buf.WriteString(args.Destination) + } default: return str, fmt.Errorf("token [%%%c] in [%s] is not supported yet", c, str) }