PHP Help -
ћNJ - 20.07.2011
Hello guys,
I'm working on my new project but recently stopped at part where I have to change linux (Debian 5.0) user password.
I can't manage to do it. Anyone knows how to etc. change password from 'something' to 'something2' for user 'marko' using PHP?
Thank You!
Re: PHP Help -
linuxthefish - 20.07.2011
Use php-ssh2 is the best way, unless you are running the webserver/fastcgi process as the user you want to change the password for
Re: PHP Help -
ћNJ - 20.07.2011
I have ssh2 module installed, what command should I run? Since 'passwd' requires user input.
Re: PHP Help -
linuxthefish - 20.07.2011
Expect allows you to "feed" the password to the passwd command.
http://linux.die.net/man/5/passwd
http://linux.die.net/man/1/expect
EDIT: Small script that might help
Код:
#!/usr/bin/expect -f
spawn passwd [lindex $argv 0]
set pass [lindex $argv 1]
expect {
password: {send "$pass\r" ; exp_continue}
eof exit
}
Place this script in /usr/bin and name it
setpasswd. You can then call the command
setpasswd username password in your PHP function or exec().
Re: PHP Help -
ћNJ - 20.07.2011
Great, can you write short code that changes users password from something to something? Thanks.
EDIT: Thanks! Rep. for you
Re: PHP Help -
linuxthefish - 20.07.2011
Done, check my last post.
Re: PHP Help -
ћNJ - 20.07.2011
Errors:
server:~# setpasswd 22005 aaa
-bash: /usr/bin/setpasswd: /usr/bin/expect: bad interpreter: No such file or directory
Re: PHP Help -
Vipero - 20.07.2011
Quote:
Originally Posted by ћNJ
Errors:
server:~# setpasswd 22005 aaa
-bash: /usr/bin/setpasswd: /usr/bin/expect: bad interpreter: No such file or directory
|
Do cd /home/22005, or where-ever you put "22005".
Re: PHP Help -
ћNJ - 20.07.2011
Alright, I cd to home directory of user 22005, still same error.
Re: PHP Help -
linuxthefish - 20.07.2011
It works for me, whats the path to expect?