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 around adding incorrect KnownHost #11

Merged
merged 2 commits into from
Dec 18, 2020

Conversation

epinault
Copy link
Contributor

Host should always be check against remote as it could be a name or an IP. but if the name is passed then it won t match the remote IP and therefore saved the incorrect entry in the known host

Host should always be check against remote as it could be a name or an IP. but if the name is passed then it won t match the remote IP and therefore saved the incorrect entry in the known host
@epinault epinault mentioned this pull request Dec 16, 2020
@melbahja
Copy link
Owner

Hi,

thanks for the PR.

I think it will be batter if we could store them both:

remoteNormalized := knownhosts.Normalize(remote.String())
hostNormalized := knownhosts.Normalize(host)
addresses := []string{remoteNormalized}

if hostNormalized != remoteNormalized {
	addresses = append(addresses, hostNormalized)
}

_, err = f.WriteString(knownhosts.Line(addresses, key) + "\n")

@melbahja
Copy link
Owner

Thanks :)

@melbahja melbahja merged commit 9d07597 into melbahja:master Dec 18, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants