What are the real rules for linux usernames on CentOS 6 and RHEL 6?

前端 未结 1 1159
感情败类
感情败类 2020-12-04 19:43

I\'m writing some web UI pages that can be used to create Linux user accounts. This web UI will be used on CentOS 6 (which is derived from RHEL 6). I\'m finding inconsiste

相关标签:
1条回答
  • 2020-12-04 20:01

    A basic gnu/linux username is a 32 character string (useradd(8)). This is a legacy format from the BSD 4.3 standard. passwd(5) adds some additional restrictions like, do not use capital letters, do not use dots, do not end it in dash, it must not include colons.

    To be on the safe side of things, follow the same rules of a C identifier:

    ([a-z_][a-z0-9_]{0,30})
    

    That's half the problem. Modern GNU/Linux distributions use PAM for user authentication. With it you can choose any rule you want and also any data source.

    Since you are writing a program it's better to define your own format, and then use something like pam_ldap, pam_mysql, etc. to access it.

    0 讨论(0)
提交回复
热议问题