Ejemplo n.º 1
0
// setKey core and root users authorized_keys to the passed key
func setKey(config *initialize.CloudConfig, key string) *initialize.CloudConfig {
	config.SSHAuthorizedKeys = append(config.SSHAuthorizedKeys, key)
	// set the password for both users
	if len(config.Users) == 0 {
		root := system.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
}