Linux自动输入密码登录用户


每次进去Linux系统,都有切换root用户,输入密码很麻烦,所以就写了一个小脚本,自动输入密码,登录到root用户,

1,首先检查一些是否安装了expect

root@wuzs:/home/wuzs# whereis expect                                                     expect: /usr/bin/expect /usr/share/man/man1/expect.1.gz

如果没有需要安装一下

apt install expect

2,代码如下

root@wuzs:/home/wuzs# cat suroot.sh                                                       #!/usr/bin/expect
set timeout 30
spawn su root
expect "Password:"
send "********\r"#此处输入密码,\r回车
interact
root@wuzs:/home/wuzs#

参考连接:https://www.cnblogs.com/lixigang/articles/4849527.html


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM