Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐛 fix issue where ssh agent authentication is not working #822

Merged
merged 1 commit into from
Jan 23, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 4 additions & 8 deletions apps/cnquery/cmd/builder/parse.go
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,10 @@ func ParseTargetAsset(cmd *cobra.Command, args []string, providerType providers.

if len(connection.Credentials) == 0 {
log.Warn().Msg("no identity file or password are provided for ssh authentication, use either --identity-file, --ask-pass or --password, fall back to ssh agent")
connection.Credentials = append(connection.Credentials, &vault.Credential{
Type: vault.CredentialType_ssh_agent,
User: username,
})
}
case providers.ProviderType_WINRM:
connection.Backend = providerType
Expand Down Expand Up @@ -647,14 +651,6 @@ func ParseTargetAsset(cmd *cobra.Command, args []string, providerType providers.
connection.Credentials = append(connection.Credentials, cred)
}

// if username was set but not credentials
if username != "" && len(connection.Credentials) == 0 {
connection.Credentials = append(connection.Credentials, &vault.Credential{
Type: vault.CredentialType_password,
User: username,
})
}

parsedAsset.Connections = []*providers.Config{connection}
return parsedAsset
}