Home > Backend Development > PHP Tutorial > 关于使用ssh2_exec修改user密码的有关问题

关于使用ssh2_exec修改user密码的有关问题

WBOY
Release: 2016-06-13 13:06:14
Original
886 people have browsed it

关于使用ssh2_exec修改user密码的问题
我要把用户名test的密码改一下,有经验的朋友看下哪里错了?感觉用ssh2_exec不太好,是不是得shell?是的话,应该怎么写???先谢谢了!

PHP code
<!--

Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/

-->
$con = ssh2_connect( 'IP', '22' );
    if ( ssh2_auth_password( $con, 'root', 'root_pwd' ) ) {
            $stream = ssh2_exec( $con, "passwd test\n123456\n123456\n" ); //把用户名“test”的密码改成“123456”
            echo $stream;
    } else echo 'Cannot log in';

Copy after login


------解决方案--------------------
"passwd test\n123456\n123456\n" 这个应该是不行的, 

试下这样
echo "123456" | passwd "test" --stdin
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template