func ListKeys(user string, mode ListMode) ([]string, error) {
	keysMutex.Lock()
	defer keysMutex.Unlock()
	keyData, err := readAuthorisedKeys(user)
	if err != nil {
		return nil, err
	}
	var keys []string
	for _, key := range keyData {
		fingerprint, comment, err := KeyFingerprint(key)
		if err != nil {
			// Only log a warning if the unrecognised key line is not a comment.
			if key[0] != '#' {
				logger.Warningf("ignoring invalid ssh key %q: %v", key, err)
			}
			continue
		}
		if mode == FullKeys {
			keys = append(keys, key)
		} else {
			shortKey := fingerprint
			if comment != "" {
				shortKey += fmt.Sprintf(" (%s)", comment)
			}
			keys = append(keys, shortKey)
		}
	}
	return keys, nil
}
// ListKeys returns either the full keys or key comments from the authorized ssh keys file for user.
ListKeys returns either the full keys or key comments from the authorized ssh keys file for user.
// ListKeys returns either the full keys or key comments from the authorized ssh keys file for user .
func ListKeys(user string, mode ListMode) ([]string, error) {
	keysMutex.Lock()
	defer keysMutex.Unlock()
	keyData, err := readAuthorisedKeys(user)
	if err != nil {
		return nil, err
	}
	var keys []string
	for _, key := range keyData {
		fingerprint, comment, err := KeyFingerprint(key)
		if err != nil {
			if key[0] != '#' {
				logger.Warningf("ignoring invalid ssh key %q: %v", key, err)
			}
			continue
		}
		if mode == FullKeys {
			keys = append(keys, key)
		} else {
			shortKey := fingerprint
			if comment != "" {
				shortKey += fmt.Sprintf(" (%s)", comment)
			}
			keys = append(keys, shortKey)
		}
	}
	return keys, nil
}
func ListKeys ( user string , mode ListMode ) ( [ ] string , error ) { keysMutex . Lock ( ) defer keysMutex . Unlock ( ) keyData , err := readAuthorisedKeys ( user ) if err != nil { return nil , err } var keys [ ] string for _ , key := range keyData { fingerprint , comment , err := KeyFingerprint ( key ) if err != nil { if key [ 0 ] != '#' { logger . Warningf ( " " , key , err ) } continue } if mode == FullKeys { keys = append ( keys , key ) } else { shortKey := fingerprint if comment != " " { shortKey += fmt . Sprintf ( " " , comment ) } keys = append ( keys , shortKey ) } } return keys , nil }
ListKeys returns either the full keys or key comments from the authorized ssh keys file for user.
ListKeys returns either the full keys or key comments from the authorized ssh keys file for user .
// Only log a warning if the unrecognised key line is not a comment.