6

I've read about what charachers should usernames use, in linux, here: https://serverfault.com/a/578264/330936 but I would like to know if is there any problem if I will use the at sign "@" in my usernames. I will use it especially for my ftp accounts (I have a simple webserver with CentOS 7).

I don't want to be portable to other older versions of linux, nor other distros (maybe debian).

Is there any problem in using @ in usernames?

MM PP
  • 269
  • 2
  • 5
  • 17
    Why would you even want to do this? This has at least the potential to create all kind of problems. – Sven Oct 20 '17 at 08:15
  • 8
    Not to mention using Unix accounts in plain text FTP server login... If you really need FTP in 2017, your FTP server probably has another way of creating accounts. – Esa Jokinen Oct 20 '17 at 08:21
  • 1
    I would like to use the cPanel style, for FTP: `name@domain.com` as ftp username – MM PP Oct 20 '17 at 08:24
  • 11
    @MMPP: The thing is that these are not plain Linux user names but virtual ones coming from a database and the `@domain.com` is not really part of the user name per se but an indication were to look this user up. – Sven Oct 20 '17 at 08:40
  • 1
    @Sven IMHO user@domain as username makes sense on multiuser server hosting multiple organizations. It does not mean it would be cost effective. – AnFi Oct 20 '17 at 09:07
  • 13
    @AnFi: The important thing is: The `@domain` is not part of the username itself, but an indication where to look the username up/which domain it belongs to. This is one of the reasons why having an `@` as part of the actual username is such a bad idea. – Sven Oct 20 '17 at 09:12
  • 2
    @MMPP If you use name@domain.com as the FTP user name, then your actual login with an FTP connection would essentially end up being name@domain.com@domain.com. Is that really what you intend? – Janus Bahs Jacquet Oct 20 '17 at 23:43
  • @JanusBahsJacquet You better make that an answer and I will vote it up. It will confuse/break most FTP clients (if they actually allow a @ in a name anyway) and will make most variants of FTP proxy handling completely impossible. Bad idea. – Tonny Oct 21 '17 at 09:57
  • 4
    By all that's holy, **do not use FTP**. Use sFTP instead and proper secure communications. – Shadur Oct 21 '17 at 14:36

2 Answers2

28

I'd say it isn't good idea.

I'd recommend to use simple regex:

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

Check following links:

https://stackoverflow.com/questions/6949667/what-are-the-real-rules-for-linux-usernames-on-centos-6-and-rhel-6

https://unix.stackexchange.com/questions/157426/what-is-the-regex-to-validate-linux-users

Jaroslav Kucera
  • 1,435
  • 10
  • 16
14

Using '@' in a username would make it impossible to use that username as the local-part of an email address, so I would say that is not a good idea.

Thomas Espe
  • 141
  • 5
  • Sounds more like a great idea if you want to make sure this user (note: not a human user) should never receive mail. – pipe Oct 20 '17 at 12:39
  • 27
    Awkward to use '@' in the local part of an email address? Yes. Will every MTA/MUA able to deal with it? Probably not. But it's neither impossible, nor invalid. `"@"@example.com` is a syntactically valid email address. –  Oct 20 '17 at 12:43
  • 5
    You're lucky if you get to the MTA/MUA stage. Most forms that request your email addr won't accept that. – ikegami Oct 20 '17 at 15:19
  • 1
    That would be a bug in said forms. – Billy left SE for Codidact Oct 20 '17 at 16:05
  • 6
    @Billy C., Of course, but that's what the user would have to deal with. – ikegami Oct 20 '17 at 17:14
  • 1
    Gmail for example isn’t following and do not allow for sending emails with comments. – Hauleth Oct 20 '17 at 17:38
  • 2
    Many email applications make a number of assumptions about email addresses. For instance, it's not uncommon for them to assume the local part is case-insensitive. So while the official standard says that it can be case-sensitive, in practice that would cause problems, so it's de facto case-insensitive. – Barmar Oct 20 '17 at 18:03
  • 7
    This basically falls under the Interoperability Principle. Since we know that there are many email clients that can't handle special characters in the local part, you need to be conservative in what characters you use there. – Barmar Oct 20 '17 at 18:04