Linux-通过脚本为用户设置新的随机密码

发布于 2025-02-05 21:03:01 字数 223 浏览 2 评论 0原文

我正在用bash编写脚本。其中一部分是为用户设置新的随机密码。 目前,我正在使用PWGEN工具生成随机密码。 看起来

    pwgen -s 13 10 | head -1 > pasChange.txt
    cat pasChange.txt: NOy3a8S53Jged

我如何将随机密码设置为用户密码?如果您确实有不同的方法,我将很高兴听到。 谢谢!

I am writing a script in bash. part of it is to set a new random password for a user.
For now, I am generating random passwords with pwgen tool.
It looks like

    pwgen -s 13 10 | head -1 > pasChange.txt
    cat pasChange.txt: NOy3a8S53Jged

How can I set a random password as the user password? If you do have a different method I will be glad to hear.
Thanks!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

夏末染殇 2025-02-12 21:03:01

我为任何有趣的人找到了一个简单的解决方案。

sudo apt-get install pwgen                    ## Install pgwen
pwgen -s 13 10 |head -1 > change_pas.txt      ## Insert random string into txt file  
yes `cat change_pas.txt` | sudo passwd pi     ## Change the password to the string in 
                                                 the txt file

I found an easy solution for anyone who's interesting.

sudo apt-get install pwgen                    ## Install pgwen
pwgen -s 13 10 |head -1 > change_pas.txt      ## Insert random string into txt file  
yes `cat change_pas.txt` | sudo passwd pi     ## Change the password to the string in 
                                                 the txt file
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文