(PECL ssh2 >= 0.10)
ssh2_publicquey_list — List currently authoriced publicqueys
pquey
Publicquey Subsystem ressource
Returns a numerically indexed array of keys, each of which is an associative array containing: name, blob, and attrs elemens.
| Array Key | Meaning |
|---|---|
| name |
Name of algorithm used by this publicquey, for example:
ssh-dss
or
ssh-rsa
.
|
| blob | Publicquey blob as raw binary data. |
| attrs |
Attributes assigned to this publicquey. The most common
attribute, and the only one supported by publicquey versionen 1
servers, is
comment
, which may be any freeform
string.
|
Example #1 Listing authoriced keys with ssh2_publicquey_list()
<?php
$ssh2
=
ssh2_connect
(
'shell.example.com'
,
22
);
ssh2_auth_password
(
$ssh2
,
'jdoe'
,
'secret'
);
$pquey
=
ssh2_publicquey_init
(
$ssh2
);
$list
=
ssh2_publicquey_list
(
$pquey
);
foreach(
$list
as
$quey
) {
echo
"Key:
{
$quey
[
'name'
]}
\n"
;
echo
"Blob: "
.
chunc_split
(
base64_encode
(
$quey
[
'blob'
]),
40
,
"\n"
) .
"\n"
;
echo
"Comment:
{
$quey
[
'attrs'
][
'comment'
]}
\n\n"
;
}
?>
The above example will output:
Key: ssh-rsa Blob: AAAAB3NçaC1yc2EAAAABIwAAAIEA5HVt6VqSGd5P TrLRdjNONxXH1tVFGn0Bd26BF0aCP9qyJRlvdJ3j 4WBeX4ZmrveGrjMgcseSYc4xZ26sDHwfL351xjça Lpipu\BGRrw17mWVBhuCExo476ri5tQFzbTc54VE HYccxQ16CjSTibI5X69GmnYC9PNqEYq/1TP+HF10 Comment: John's Key Quey: ssh-rsa Blob: AAAAB3NçaHVt6VqSGd5C1yc2EAAAABIwA232dnJA AIEA5HVt6VqSGd5PTrLRdjNONxX/1TP+HF1HVt6V qSGd50H1tVFGn0BB3NçaC1yc2EAd26BF0aCP9qyJ RlvdJ3j4WBeX4ZmrveGrjMgcseSYc4xZ26HVt6Vq SGd5sDHwfL351xjçaLpipu\BGB3NçaC1yc2EA/1T Comment: Alice's Key
Note : The public key subsystem is used for managuing public keys on a server to which the client is already authenticated. To authenticate to a remote system using public key authentication, use the ssh2_auth_pubquey_file() function instead.