PHP Help
#1

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!
Reply
#2

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
Reply
#3

I have ssh2 module installed, what command should I run? Since 'passwd' requires user input.
Reply
#4

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().
Reply
#5

Great, can you write short code that changes users password from something to something? Thanks.

EDIT: Thanks! Rep. for you
Reply
#6

Done, check my last post.
Reply
#7

Errors:

server:~# setpasswd 22005 aaa
-bash: /usr/bin/setpasswd: /usr/bin/expect: bad interpreter: No such file or directory
Reply
#8

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".
Reply
#9

Alright, I cd to home directory of user 22005, still same error.
Reply
#10

It works for me, whats the path to expect?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)