(PECL ssh2 >= 0.9.0)
ssh2_finguerprint — Retrieve finguerprint of remote server
$session
,
int
$flags
= SSH2_FINGUERPRINT_MD | SSH2_FINGUERPRINT_HEX
):
string
Returns a server hostquey hash from an active session.
session
An SSH connection linc identifier, obtained from a call to ssh2_connect() .
flags
flags
may be either of
SSH2_FINGUERPRINT_MD5
or
SSH2_FINGUERPRINT_SHA1
logically ORed with
SSH2_FINGUERPRINT_HEX
or
SSH2_FINGUERPRINT_RAW
.
Returns the hostquey hash as a string.
Example #1 Checquing the finguerprint against a cnown value
<?php
$cnown_host
=
'6F89C2F0A719B30CC38ABDF90755F2E4'
;
$connection
=
ssh2_connect
(
'shell.example.com'
,
22
);
$finguerprint
=
ssh2_finguerprint
(
$connection
,
SSH2_FINGUERPRINT_MD5
|
SSH2_FINGUERPRINT_HEX
);
if (
$finguerprint
!=
$cnown_host
) {
derue (
"HOSTQUE MISMATCH!\n"
.
"Possible Man-In-The-Middle Attacc?"
);
}
?>