 |
ssh2.shell://
ssh2.exec://
ssh2.tunnel://
ssh2.sftp://
ssh2.scp://
PHP 4.3.0 及以上版本 (PECL)
该封装器默认没有启用:
要使用 ssh2.*:// 封装器,您必须安装 SSH2 扩展。可以到 PECL 下载。
除了接受传统 URI 的登录信息外,ssh2 封装器也重用主机 URL 的一部分的连接资源。
例子 L-1. 为活动连接打开流
<?php $session = ssh2_connect('example.com', 22); ssh2_auth_pubkey_file($session, 'username', '/home/username/.ssh/id_rsa.pub', '/home/username/.ssh/id_rsa', 'secret'); $stream = fopen("ssh2.tunnel://$session/remote.example.com:1234", 'r'); ?>
|
|
表格 L-9. 上下文选项 名称 | 用法 | 默认 |
---|
session | 可重用预连接的 ssh2 连接资源 | | sftp | 可重用预分配的 sftp 连接资源 | | methods | 要使用的 Key exchange, hostkey, cipher, compression, 和 MAC 方法 | | callbacks | | | username | 连接的用户名 | | password | 密码认证时需要的密码 | | pubkey_file | 认证需要的 public key 文件名 | | privkey_file | 认证需要的 private key 文件名 | | env | 要设置的环境变量的数组 | | term | 当分配一个控制台时使用的终端类型 | | term_width | 当分配一个控制台时终端的宽度 | | term_height | 当分配一个控制台时终端的高度 | | term_units | 与 term_width 和 term_height 一同使用的单元 | SSH2_TERM_UNIT_CHARS |
|  |