ssh2.shell:// ssh2.exec:// ssh2.tunnel:// ssh2.sftp:// ssh2.scp:// PHP 4.3.0 及以上版本 (PECL)
ssh2.shell://user:pass@example.com:22/xterm
ssh2.exec://user:pass@example.com:22/usr/local/bin/somecmd
ssh2.tunnel://user:pass@example.com:22/192.168.0.1:14
ssh2.sftp://user:pass@example.com:22/path/to/filename
该封装器默认没有启用: 要使用 ssh2.*:// 封装器,必须安装 SSH2 扩展。可以到 PECL 下载。
除了接受传统 URI 的登录信息外,ssh2 封装器也重用主机 URL 的一部分的连接资源。
例 O-2. 为活动连接打开流
<?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'); ?>
表 O-8. 封装协议摘要
表 O-9. 上下文选项