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

Generate a random ssh password per kluster #162

Merged
merged 2 commits into from
Jan 12, 2018
Merged

Generate a random ssh password per kluster #162

merged 2 commits into from
Jan 12, 2018

Conversation

databus23
Copy link
Member

@databus23 databus23 commented Jan 11, 2018

Instead of hardcoding a global password into the ignition template we now generate a random 12 char password for each kluster and use that in the ignition templates for the kluster nodes.
Existing klusters that don’t have this are staying on the old hard coded value for now.

This password is not exposed anyware at the moment. Its meant as a diagnostic backdoor during the techpreview. We can think about exposing this password to the enduser in the future.

Manually tested that this actually works.

@databus23 databus23 requested a review from BugRoger January 11, 2018 14:52
@databus23 databus23 requested a review from SchwarzM as a code owner January 11, 2018 14:52
@databus23 databus23 force-pushed the sshpassword branch 3 times, most recently from 296af41 to 9c59703 Compare January 11, 2018 14:57
bootstrapToken: {{ required "missing boostrapToken" .Values.bootstrapToken | b64enc }}
token.csv: {{ include (print $.Template.BasePath "/_token.csv.tpl") . | b64enc }}
node-password: {{ required "missing node-password" .Values.nodePassword | b64enc }}
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you also update the chart version to master-1.9.0-kubernikus.1? Even though this is informational only, we can see why Kluster is using which chart version.

🐢  > helm ls                                                                                                                                                                                                                                                                                                         0 ↵
NAME                                  	REVISION	UPDATED                 	STATUS  	CHART                         	NAMESPACE
test2-8b25871959204ff1a27605b7bcf873f7	1       	Tue Jan  9 11:34:00 2018	DEPLOYED	kube-master-1.9.0-kubernikus.0	kubernikus
v6-5d725ddf97664a16b011e8a8dd75772b   	1       	Fri Jan 12 11:36:08 2018	DEPLOYED	kube-master-1.9.0-kubernikus.0	kubernikus-michi

Copy link
Member Author

Choose a reason for hiding this comment

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

I can do that, yes

@@ -61,6 +63,26 @@ func (i *ignition) GenerateNode(kluster *kubernikusv1.Kluster, secret *v1.Secret
return nil, err
}

//this is the old default for backwards comptibility with clusters that don't have a passwort generated
//TODO: Remove once all klusters are upgraded
passwordHash := "$6$rounds=1000000$aldshc,xbneroyw$I756LN/FtceE1deC2H.tGeSdeeelaaZWRwzmbEuO1SANf7ssyPjnbQjlW/FcMvWGUGrhF64tX9fK0abE/4oQ80"
Copy link
Contributor

Choose a reason for hiding this comment

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

wth? 🤣

Copy link
Member Author

Choose a reason for hiding this comment

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

Thats just the old password salted and hashed 1 million times with sha512. Nothing special.
image

//Reason for this is we expose the resulting hash in the metadata service which is not very secure.
//It takes about 500ms on my workstation to compute this hash. So this means login to a node is also
// delayed for about a second which should be ok as this password is only meant as a last resort.
passwordHash, err = passwordCrypter.Generate(nodePassword, append([]byte("$6$rounds=1000000$"), salt...))
Copy link
Contributor

Choose a reason for hiding this comment

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

How long and complicated is the resulting password? It often needs to be entered in the crappy VPC console without copy-paste...

Copy link
Member Author

Choose a reason for hiding this comment

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

Its 12 chars and only characters and numbers. Its ok, I tested it.

@@ -6,7 +6,7 @@ var Node_1_7 = `
passwd:
users:
- name: core
password_hash: xyTGJkB462ewk
password_hash: {{ .LoginPassword }}
ssh_authorized_keys:
- "ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAvFapuevZeHFpFn438XMjvEQYd0wt7+tzUdAkMiSd007Tx1h79Xm9ZziDDUe4W6meinVOq93MAS/ER27hoVWGo2H/vn/Cz5M8xr2j5rQODnrF3RmfrJTbZAWaDN0JTq2lFjmCHhZJNhr+VQP1uw4z2ofMBP6MLybnLmm9ukzxFYZqCCyfEEUTCMA9SWywtTpGQp8VLM4INCxzBSCuyt3SO6PBvJSo4HoKg/sLvmRwpCVZth48PI0EUbJ72wp88Cw3bv8CLce2TOkLMwkE6NRN55w2aOyqP1G3vixHa6YcVaLlkQhJoJsBwE3rX5603y2KjOhMomqHfXxXn/3GKTWlsQ== [email protected]"
Copy link
Contributor

Choose a reason for hiding this comment

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

Remove this key

Copy link
Member Author

Choose a reason for hiding this comment

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

I will with the ssh public key PR I'm working on.

@databus23 databus23 force-pushed the sshpassword branch 4 times, most recently from 1b16def to 2770afc Compare January 12, 2018 14:19
Instead of hardcoding a global password into the ignition template we now generate a random 12 char password for each kluster and use that in the ignition templates for the kluster nodes.
Existing klusters that don’t have this are staying on the old hard coded password for now.

This password is not exposed anyware at the moment. Its meant as a diagnostic backdoor during the techpreview. We can think about exposing this password to the enduser in the future.

Manually tested that this actually works.
@databus23 databus23 merged commit d9a7513 into master Jan 12, 2018
@databus23 databus23 deleted the sshpassword branch January 12, 2018 15:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants