getServerPublicHostKey() public method

Caching this the first time you connect to a server and checking the result on subsequent connections is recommended. Returns false if the server signature is not signed correctly with the public host key.
public getServerPublicHostKey ( ) : mixed
return mixed
Ejemplo n.º 1
0
 /**
  * @param string $hashingMethod "sha1" or "md5"
  * @return mixed
  */
 public function getForeignKeyFingerprint($hashingMethod)
 {
     switch ($hashingMethod) {
         case self::HASHING_SHA1:
             $hashingMethod = function ($string) {
                 return sha1($string);
             };
             break;
         case self::HASHING_MD5:
         default:
             $hashingMethod = function ($string) {
                 return md5($string);
             };
     }
     $foreignPublicKey = explode(' ', $this->ssh->getServerPublicHostKey());
     return $hashingMethod(base64_decode($foreignPublicKey[1]));
 }
Ejemplo n.º 2
0
 public function testGetServerPublicHostKey()
 {
     $ssh = new SSH2($this->getEnv('SSH_HOSTNAME'));
     $this->assertInternalType('string', $ssh->getServerPublicHostKey());
 }