fix: problems with quotes from Host names and support SSH tokens (issue #32)

This commit is contained in:
2026-01-04 22:21:13 +01:00
parent 8f780e288c
commit 87f8fb9c6c
4 changed files with 119 additions and 1 deletions

View File

@@ -283,8 +283,12 @@ func parseSSHConfigFileWithProcessedFiles(configPath string, processedFiles map[
hostNames := strings.Fields(value)
// Skip hosts with wildcards (*, ?) as they are typically patterns, not actual hosts
// Also remove surrounding quotes from host names
var validHostNames []string
for _, hostName := range hostNames {
// Remove surrounding double quotes if present
hostName = strings.Trim(hostName, `"`)
if !strings.ContainsAny(hostName, "*?") {
validHostNames = append(validHostNames, hostName)
}
@@ -896,6 +900,9 @@ func quickHostSearchInFile(hostName string, configPath string, processedFiles ma
// Check if our target host is in this Host declaration
for _, candidateHostName := range hostNames {
// Remove surrounding double quotes if present
candidateHostName = strings.Trim(candidateHostName, `"`)
// Skip hosts with wildcards (*, ?) as they are typically patterns
if !strings.ContainsAny(candidateHostName, "*?") && candidateHostName == hostName {
return true, nil // Found the host!