|
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 的一部分的連線資源。
例子 M-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'); ?>
|
|
表格 M-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 |
| |