×

Loading...
Ad by
  • 推荐 OXIO 加拿大高速网络,最低月费仅$40. 使用推荐码 RCR37MB 可获得一个月的免费服务
Ad by
  • 推荐 OXIO 加拿大高速网络,最低月费仅$40. 使用推荐码 RCR37MB 可获得一个月的免费服务

humm, sounds interesting, i will look on it. i found the solution, detail see inside. thanks gettext and oasis

vi mkqpasswd (for qmail account under RH Linux)

#!/usr/bin/expect -f
set password [lindex $argv 1]
spawn passwd [lindex $argv 0]
sleep 2
expect "password:"
sleep 10
send "$password\r"
sleep 10
expect "password:"
sleep 10
send "$password\r"
sleep 10
expect eof

#useradd toto
#./mkqpasswd toto p0o9I8U7y6

clear the .bash_history if you are security paranoid...

the sleep is necessary, i connect to office linux server with 33.6 modem, i put 5, didn't work, so i put 10, it works fine now. if i work locally, possible i need only 5, i will check this later.
i also tried with the mkpasswd come with expect(1), it didn't work either.

ps1: you can find expect rpm in cd 2 of RH Linux, it is not installed by default, strange thought.
ps2: beware of your version of *unix, some version has strong passwd scheme configured, try give a REAL passwd.
Report

Replies, comments and Discussions:

  • 工作学习 / IT技术讨论 / 请教:如何在RHLinux下用shell scirpt or perl 自动加password? 在线等。
    i have around 250 account to add, i don't want to add one by one, special for passwd, someone has any idea to do this under RH Linux.

    any help wil be appreciated.

    thanks
    • # for (( i=0; i<250; i++ )); do useradd test$i -p test$i; done
      • useradd -p is not for passwd, i tried, it just didn't work. anyone know well expect(1) or a program call pty?
    • 也许能有点帮助
      useradd -p passwd user
      但是passwd不是你的password, 你的password是加密之后的
      then modify your passwd
      echo passwd |passwd --stdin user
      • humm, sounds interesting, i will look on it. i found the solution, detail see inside. thanks gettext and oasis
        vi mkqpasswd (for qmail account under RH Linux)

        #!/usr/bin/expect -f
        set password [lindex $argv 1]
        spawn passwd [lindex $argv 0]
        sleep 2
        expect "password:"
        sleep 10
        send "$password\r"
        sleep 10
        expect "password:"
        sleep 10
        send "$password\r"
        sleep 10
        expect eof

        #useradd toto
        #./mkqpasswd toto p0o9I8U7y6

        clear the .bash_history if you are security paranoid...

        the sleep is necessary, i connect to office linux server with 33.6 modem, i put 5, didn't work, so i put 10, it works fine now. if i work locally, possible i need only 5, i will check this later.
        i also tried with the mkpasswd come with expect(1), it didn't work either.

        ps1: you can find expect rpm in cd 2 of RH Linux, it is not installed by default, strange thought.
        ps2: beware of your version of *unix, some version has strong passwd scheme configured, try give a REAL passwd.
        • I find expect is not a shell command, now, I know why, thanks for your sharing.