(PECL ssh2 >= 0.9.0)
ssh2_auth_hostbased_file — 使用公開主機金鑰進行驗證
$session,$username,$hostname,$pubkeyfile,$privkeyfile,$passphrase = ?,$local_username = ?使用從檔案讀取的公開主機金鑰進行驗證。
session一個 SSH 連線連結識別碼,從呼叫 ssh2_connect() 取得。
username
hostname
pubkeyfile
privkeyfile
passphrase如果 privkeyfile 已加密(應該如此),則必須提供 passphrase。
local_username如果省略 local_username,則會使用 username 的值。
範例 #1 使用公開主機金鑰驗證
<?php
$connection = ssh2_connect('shell.example.com', 22, array('hostkey'=>'ssh-rsa'));
if (ssh2_auth_hostbased_file($connection, 'remoteusername', 'myhost.example.com',
'/usr/local/etc/hostkey_rsa.pub',
'/usr/local/etc/hostkey_rsa', 'secret',
'localusername')) {
echo "公開金鑰主機驗證成功\n";
} else {
die('公開金鑰主機驗證失敗');
}
?>注意:
ssh2_auth_hostbased_file() 需要 libssh2 >= 0.7 以及 PHP/SSH2 >= 0.7