useradd -M -s /sbin/nologin -n username

ubuntu 下对应的 shell 应该是 `/bin/false`, CentOS 才是 `/sbin/nologin`

所以应该是

useradd -M -s /bin/false -n username

修正错误

chsh username -s /bin/bash

参考地址 https://www.v2ex.com/t/123803