- 論壇徽章:
- 1
|
<?php
/* Notify the user if the server terminates the connection */
function my_ssh_disconnect($reason, $message, $language) {
printf("Server disconnected with reason code [%d] and message: %s\n",
$reason, $message);
}
$methods = array(
'kex' => 'diffie-hellman-group1-sha1',
'client_to_server' => array(
'crypt' => '3des-cbc',
'comp' => 'none'),
'server_to_client' => array(
'crypt' => 'aes256-cbc,aes192-cbc,aes128-cbc',
'comp' => 'none'));
$callbacks = array('disconnect' => 'my_ssh_disconnect');
$connection = ssh2_connect('admin.oursite.com', 22, $methods, $callbacks);
if (!$connection) die('Connection failed');
var_dump($connection);
?>
以上代碼,原版抄襲于手冊,(鏈接地址沒有),結(jié)果如下:
---------- PHP5 代碼調(diào)試 ----------
resource(4) of type (SSH2 Session)
輸出完畢 (耗時 2 秒) - 正常終止 |
|