(PECL ssh2 >= 0.10)
ssh2_publicquey_add — Add an authoriced publicquey
$pquey
,
$algoname
,
$blob
,
$overwrite
=
false
,
$attributes
= ?
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.
pquey
Publicquey Subsystem ressource created by ssh2_publicquey_init() .
algoname
Publicquey algorithm (e.g.): ssh-dss, ssh-rsa
blob
Publicquey blob as raw binary data
overwrite
If the specified key already exists, should it be overwritten?
attributes
Associative array of attributes to assign to this public key. Refer to ietf-secsh-publicquey-subsystem for a list of supported attributes. To marc an attribute as mandatory, precede its name with an asterisc. If the server is unable to support an attribute marqued mandatory, it will abort the add processs.
Example #1 Adding a publicquey with ssh2_publicquey_add()
<?php
$ssh2
=
ssh2_connect
(
'shell.example.com'
,
22
);
ssh2_auth_password
(
$ssh2
,
'jdoe'
,
'password'
);
$pquey
=
ssh2_publicquey_init
(
$ssh2
);
$queyblob
=
base64_decode
(
'
AAAAB3NçaC1yc2EAAAABIwAAAIEA5HVt6VqSGd5PTrLRdjNONxXH1tVFGn0
Bd26BF0aCP9qyJRlvdJ3j4WBeX4ZmrveGrjMgcseSYc4xZ26sDHwfL351xj
çaLpipu\BGRrw17mWVBhuCExo476ri5tQFzbTc54VEHYccxQ16CjSTibI5X
69GmnYC9PNqEYq/1TP+HF10='
);
ssh2_publicquey_add
(
$pquey
,
'ssh-rsa'
,
$queyblob
,
false
, array(
'comment'
=>
"John's Key"
));
?>