Home > php教程 > php手册 > body text

php ssh2 函数学习

WBOY
Release: 2016-06-06 19:43:25
Original
2297 people have browsed it

ssh2 是 php 中的一个模块,它的作用就是是登录remote主机来进行操作 但现在关于它的中文本资料很少,只能先了解一点,记录一点了,慢慢再完善 ssh2_connect($host, $port); ssh2_auth_password($resource, $user, $password); password验证方式 ssh2_sftp($

ssh2 是 php 中的一个模块,它的作用就是是登录remote主机来进行操作

但现在关于它的中文本资料很少,只能先了解一点,记录一点了,慢慢再完善

ssh2_connect($host, $port);

ssh2_auth_password($resource, $user, $password); password验证方式

ssh2_sftp($resource); 产生sftp句柄

ssh2_scp_send();       类似scp命令

ssh2_exec($resource, $cmd); 执行命令

ssh2_sftp_stat($resource_sftp, $dir); 查看目录

ssh2_sftp_mkdir($resoruce_sftp, $dir); 创建目录

其中有的是connetc句柄,而有的则是sftp句柄,

ssh2_exec() 是会有返回值的,而它的返回值是无格式的(无换行),但它是以stream(流的形式返回),

显示出来,可这样进行流处理:

stream_set_blocking($stream, true);

echo :stream_get_contents($stream);

 

用php来登录ssh 远程主机,不如用putty等终端命令灵活,所以封装了一些函数用来进行常用的操作,如:

ssh_sftp_mkdir() 等等

 

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
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!