Skip to content
This repository has been archived by the owner on Jan 30, 2020. It is now read-only.

fleetctl appends port number in ~/.fleetctl/known_hosts #410

Merged
merged 10 commits into from
May 9, 2014

Conversation

jonboulle
Copy link
Contributor

By default when generating a known_hosts file, fleet appends the port number. This is problematic for two reasons.

  1. if the port number is 22 it should not be included
  2. if the port number is not 22 then the ip address should be enclosed in square braces and the port should be appended afterwards (e.g. [192.168.1.1]:22). This is because IPv6 addresses utilize colons as a delimiter. For more information, man sshd - section "SSH_KNOWN_HOSTS FILE FORMAT".

@bcwaldon bcwaldon added this to the v0.3.1 milestone May 7, 2014
This change also adds sshDefaultPort in the ssh module only if necessary
rather than tacking it on arbitrarily in fleetctl.
@jonboulle
Copy link
Contributor

@brianredbeard ptal

@jonboulle
Copy link
Contributor

Actually, stand by - I'm going to rework the known hosts functionality to better match the spec.

@jonboulle
Copy link
Contributor

Well, that was a fun rabbit hole. It turns out the known hosts spec is rather.. intricate, and we were barely scratching the surface of it.

This implements the vast majority of it (and adds coverage for pretty much all new code), but still a bit more cleanup to be done.

var i, j int
for i < len(p) {
if p[i] == '*' {
/* Skip the asterisk. */
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Its like these comments read with an Australian accent...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we keep with the style of the rest of the codebase and use double-slash comments?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK

@@ -92,6 +92,7 @@ func TestHostLine(t *testing.T) {
}

// TestHostKeyFile tests to read and write from HostKeyFile
/*
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Excuse me?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Patience young padawan

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, should I hold off on reviewing this PR for now?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well I'm reworking the tests, but feel free to tear into the rest.

@bcwaldon
Copy link
Contributor

bcwaldon commented May 9, 2014

@jonboulle Not sure where we're at here, but I tested it out anyways:

% cat ~/.fleetctl/known_hosts
127.0.0.1:2222 ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCki6T4lAFTlJ0HzuboJoB83aiDCjDiXm2DCjg0FLsAunQrMH3Z9tEko5j7d3G/GJTdBqdhFAkMSbbS7ceJYUTkRuHLE1VXQSbyhJCeNT/Cw8rQxfi2pq45AylGzHw304IUBZxOwsnSKsK9uWK3XRMNO+1oQs0ZrPvFkiPkq7Szd0e7FkaF7RDoe4ZHPw8EONcnbhiCfFw6W1ZaCoGTFdk6B3Rn9JoGsYHsyU+42yz7oGxeFQZzUmko4xc842aAFoT9geWhsD1m0AQgrsZ/e1l73WaAiaYhPzgaHcUN2naewsfP9e6qqBvaMPTmPoy9RP3JsZREEh6NLImoo3/kPTxf

The hostname in that entry doesn't seem correct. Shouldn't it be [127.0.0.1]:2222?

@jonboulle
Copy link
Contributor

You are correct. I misread net.JoinHostPort, it doesn't actually do what we want - so now we just use a direct translation from openssh.

@jonboulle
Copy link
Contributor

(also, the test was wrong - fixed)

@bcwaldon
Copy link
Contributor

bcwaldon commented May 9, 2014

Working as expected now, but what do you think about compatibility with the old host format? I ran both latest and this fleetctl and they ignored eachother in the known_hosts file. Maybe this patch should take into account the old host format?

% cat ~/.fleetctl/known_hosts
127.0.0.1:2222 ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCki6T4lAFTlJ0HzuboJoB83aiDCjDiXm2DCjg0FLsAunQrMH3Z9tEko5j7d3G/GJTdBqdhFAkMSbbS7ceJYUTkRuHLE1VXQSbyhJCeNT/Cw8rQxfi2pq45AylGzHw304IUBZxOwsnSKsK9uWK3XRMNO+1oQs0ZrPvFkiPkq7Szd0e7FkaF7RDoe4ZHPw8EONcnbhiCfFw6W1ZaCoGTFdk6B3Rn9JoGsYHsyU+42yz7oGxeFQZzUmko4xc842aAFoT9geWhsD1m0AQgrsZ/e1l73WaAiaYhPzgaHcUN2naewsfP9e6qqBvaMPTmPoy9RP3JsZREEh6NLImoo3/kPTxf
[127.0.0.1]:2222 ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCki6T4lAFTlJ0HzuboJoB83aiDCjDiXm2DCjg0FLsAunQrMH3Z9tEko5j7d3G/GJTdBqdhFAkMSbbS7ceJYUTkRuHLE1VXQSbyhJCeNT/Cw8rQxfi2pq45AylGzHw304IUBZxOwsnSKsK9uWK3XRMNO+1oQs0ZrPvFkiPkq7Szd0e7FkaF7RDoe4ZHPw8EONcnbhiCfFw6W1ZaCoGTFdk6B3Rn9JoGsYHsyU+42yz7oGxeFQZzUmko4xc842aAFoT9geWhsD1m0AQgrsZ/e1l73WaAiaYhPzgaHcUN2naewsfP9e6qqBvaMPTmPoy9RP3JsZREEh6NLImoo3/kPTxf

@brianredbeard
Copy link
Member Author

I think if it politely ignores old entries and doesn't put undue burden on
the users it should be fine. Thoughts?

On Fri, May 9, 2014 at 1:17 PM, Brian Waldon [email protected]:

Working as expected now, but what do you think about compatibility with
the old host format? I ran both latest and this fleetctl and they ignored
eachother in the known_hosts file. Maybe this patch should take into
account the old host format?

% cat ~/.fleetctl/known_hosts127.0.0.1:2222 ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCki6T4lAFTlJ0HzuboJoB83aiDCjDiXm2DCjg0FLsAunQrMH3Z9tEko5j7d3G/GJTdBqdhFAkMSbbS7ceJYUTkRuHLE1VXQSbyhJCeNT/Cw8rQxfi2pq45AylGzHw304IUBZxOwsnSKsK9uWK3XRMNO+1oQs0ZrPvFkiPkq7Szd0e7FkaF7RDoe4ZHPw8EONcnbhiCfFw6W1ZaCoGTFdk6B3Rn9JoGsYHsyU+42yz7oGxeFQZzUmko4xc842aAFoT9geWhsD1m0AQgrsZ/e1l73WaAiaYhPzgaHcUN2naewsfP9e6qqBvaMPTmPoy9RP3JsZREEh6NLImo
o3/kPTxf
[127.0.0.1]:2222 ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCki6T4lAFTlJ0HzuboJoB83aiDCjDiXm2DCjg0FLsAunQrMH3Z9tEko5j7d3G/GJTdBqdhFAkMSbbS7ceJYUTkRuHLE1VXQSbyhJCeNT/Cw8rQxfi2pq45AylGzHw304IUBZxOwsnSKsK9uWK3XRMNO+1oQs0ZrPvFkiPkq7Szd0e7FkaF7RDoe4ZHPw8EONcnbhiCfFw6W1ZaCoGTFdk6B3Rn9JoGsYHsyU+42yz7oGxeFQZzUmko4xc842aAFoT9geWhsD1m0AQgrsZ/e1l73WaAiaYhPzgaHcUN2naewsfP9e6qqBvaMPTmPoy9RP3JsZREEh6NLImoo3/kPTxf


Reply to this email directly or view it on GitHubhttps://github.com//pull/410#issuecomment-42708925
.

@bcwaldon
Copy link
Contributor

bcwaldon commented May 9, 2014

@brianredbeard I think I agree, just wanted to have the conversation on the record. At least we don't have to worry about fleetctl ignoring host keys or something terrible like that.

@jonboulle
Copy link
Contributor

Yeah, I'd rather avoid accounting for the old host format - it complicates the logic a bit, and technically it's an invalid format anyway (our bad).

@bcwaldon
Copy link
Contributor

bcwaldon commented May 9, 2014

🐑 it

@bcwaldon
Copy link
Contributor

bcwaldon commented May 9, 2014

btw that 🐑 it is a 🚢 it

@jonboulle
Copy link
Contributor

Ship from phone.

jonboulle added a commit that referenced this pull request May 9, 2014
fleetctl appends port number in ~/.fleetctl/known_hosts
@jonboulle jonboulle merged commit 96494da into coreos:master May 9, 2014
@bcwaldon
Copy link
Contributor

bcwaldon commented May 9, 2014

Like a boss

@jonboulle jonboulle deleted the 410 branch May 9, 2014 22:45
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants