Example #1
0
// config.SSHAuthorizedKeys sets the "core" user, the other sets the root
func setKey(config *cloudinit.CloudConfig, key string) *cloudinit.CloudConfig {
	config.SSHAuthorizedKeys = append(config.SSHAuthorizedKeys, key)
	// set the password for both users
	if len(config.Users) == 0 {
		root := cloudinit.User{
			Name: "root",
		}
		root.SSHAuthorizedKeys = append(root.SSHAuthorizedKeys, key)
		config.Users = append(config.Users, root)
	} else {
		config.Users[0].SSHAuthorizedKeys = append(config.Users[0].SSHAuthorizedKeys, key)
	}
	return config
}