ssh2_fingerprint

(PECL ssh2 >= 0.9.0)

ssh2_fingerprintUzak sunucunu parmakizini döndürür

Açıklama

ssh2_fingerprint(resource $oturum, int $seçenekler = SSH2_FINGERPRINT_MD5 | SSH2_FINGERPRINT_HEX): string

Etkin oturumdan sunucunun konak anahtarı aşını döndürür.

Değiştirgeler

oturum

ssh2_connect() ile sağlanan bir SSH bağlantı tanıtıcısı.

seçenekler

SSH2_FINGERPRINT_MD5 veya SSH2_FINGERPRINT_SHA1 ile SSH2_FINGERPRINT_HEX veya SSH2_FINGERPRINT_RAW bitsel olarak VEYAlanabilir.

Dönen Değerler

Konak anahtarı aşını bir dizge olarak döndürür.

Örnekler

Örnek 1 - Parmakizini karşılaştırmak

<?php
$bildik_konak 
'6F89C2F0A719B30CC38ABDF90755F2E4';

$baglanti ssh2_connect('shell.example.com'22);

$parmakizi ssh2_fingerprint($connection,
               
SSH2_FINGERPRINT_MD5 SSH2_FINGERPRINT_HEX);

if (
$parmakizi != $bildik_konak) {
  die(
"ANAHTAR UYMADI!\n" .
      
"Kimle dansediyoruz, acaba?!);
}
?>

add a note add a note

User Contributed Notes 1 note

up
-15
Lyle Mantooth
10 years ago
If you're going to compare the fingerprint to a user-submitted form field, it's probably a good idea to do case-insensitive comparison:
<?php

if ($conn = ssh2_connect($user, $password)) {
   
$fingerprint = ssh2_fingerprint($conn);
    if (
strcasecmp($fingerprint, $known_value) === 0) {
       
// Do your thing.
   
}
}
?>
Of course, this is only necessary when you use the SSH2_FINGERPRINT_HEX option, not SSH2_FINGERPRINT_RAW.
To Top