func ReplaceKeys(user string, newKeys ...string) error {
	keysMutex.Lock()
	defer keysMutex.Unlock()

	existingKeyData, err := readAuthorisedKeys(user)
	if err != nil {
		return err
	}
	var existingNonKeyLines []string
	for _, line := range existingKeyData {
		_, _, err := KeyFingerprint(line)
		if err != nil {
			existingNonKeyLines = append(existingNonKeyLines, line)
		}
	}
	return writeAuthorisedKeys(user, append(existingNonKeyLines, newKeys...))
}
// ReplaceKeys writes the specified ssh keys to the authorized_keys file for user,
// replacing any that are already there.
// Returns an error if there is an issue with *any* of the supplied keys.
ReplaceKeys writes the specified ssh keys to the authorized_keys file for user,
replacing any that are already there.
Returns an error if there is an issue with *any* of the supplied keys.
// ReplaceKeys writes the specified ssh keys to the authorized_keys file for user // replacing any that are already there . // Returns an error if there is an issue with * any * of the supplied keys .
func ReplaceKeys(user string, newKeys ...string) error {
	keysMutex.Lock()
	defer keysMutex.Unlock()
	existingKeyData, err := readAuthorisedKeys(user)
	if err != nil {
		return err
	}
	var existingNonKeyLines []string
	for _, line := range existingKeyData {
		_, _, err := KeyFingerprint(line)
		if err != nil {
			existingNonKeyLines = append(existingNonKeyLines, line)
		}
	}
	return writeAuthorisedKeys(user, append(existingNonKeyLines, newKeys...))
}
func ReplaceKeys ( user string , newKeys ... string ) error { keysMutex . Lock ( ) defer keysMutex . Unlock ( ) existingKeyData , err := readAuthorisedKeys ( user ) if err != nil { return err } var existingNonKeyLines [ ] string for _ , line := range existingKeyData { _ , _ , err := KeyFingerprint ( line ) if err != nil { existingNonKeyLines = append ( existingNonKeyLines , line ) } } return writeAuthorisedKeys ( user , append ( existingNonKeyLines , newKeys ... ) ) }
ReplaceKeys writes the specified ssh keys to the authorized_keys file for user,
replacing any that are already there.
ReplaceKeys writes the specified ssh keys to the authorized_keys file for user replacing any that are already there .