我有一个在Centos上运行正常的脚本,因为useradd不需要在那里设置密码,但是同样的脚本不需要在Ubuntu服务器上工作,因为它需要这个信息。
我理想的情况是,不要在我的脚本上为ubuntu服务器强制设置密码,要么在useradd命令中添加一行代码设置密码。
如果我只是将sudo passwd 用户添加到我的脚本中,则只会在useradd命令后才生效。
有任何想法吗?
从man adduser
:
--disabled-password Like --disabled-login, but logins are still possible (for example using SSH RSA keys) but not using password authentication.
useradd
上的默认行为是禁用密码,以便已经工作。