note 128835 added to function.ssh2-connect
| From: | devoldemar at main dot php dot net | Date: | Mon, 28 Aug 2023 11:50:11 +0000 |
| Subject: | note 128835 added to function.ssh2-connect | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-220797@lists.php.net to get a copy of this message | ||
Usage of 'hostkey' option makes sence when you need to check authenticity of the remote
server, e.g. by means of ssh2_fingerprint function. For that purpose you specify a list of possible
algorithms sorted by priority in descending order. Supported values also include
'ssh-ed25519', 'ecdsa-sha2-nistp256', 'ecdsa-sha2-nistp384' and
'ecdsa-sha2-nistp521'.
For instance:
<?php
$ssh = ssh2_connect('192.168.3.1', 22, ['hostkey' =>
'ssh-ed25519,ssh-rsa']);
$md5 = ssh2_fingerprint($ssh); // returns MD5 hash of ED25519 host key, or MD5 hash of RSA key if
the key of previous type is absent
?>
Note, if the remote server does not have a key of appropriate type connection will fail:
<?php
$ssh = ssh2_connect('192.168.3.1', 22, ['hostkey' => 'ssh-dss']);
PHP Warning: ssh2_connect(): Error starting up SSH connection(-5): Unable to exchange encryption
keys in php shell code on line 1
PHP Warning: ssh2_connect(): Unable to connect to 192.168.3.1 in php shell code on line 1
?>
----
Server IP: 45.112.84.4
Probable Submitter: 45.91.157.134 (proxied: 151.236.39.105)
----
Manual Page -- https://php.net/manual/en/function.ssh2-connect.php
Edit -- https://main.php.net/note/edit/128835
Del: integrated -- https://main.php.net/note/delete/128835/integrated
Del: useless -- https://main.php.net/note/delete/128835/useless
Del: bad code -- https://main.php.net/note/delete/128835/bad+code
Del: spam -- https://main.php.net/note/delete/128835/spam
Del: non-english -- https://main.php.net/note/delete/128835/non-english
Del: in docs -- https://main.php.net/note/delete/128835/in+docs
Del: other reasons-- https://main.php.net/note/delete/128835
Reject -- https://main.php.net/note/reject/128835
Search -- https://main.php.net/manage/user-notes.php