-
Notifications
You must be signed in to change notification settings - Fork 855
Document ssh2_auth_pubkey() from pecl/ssh2 v1.4 #5010
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
cweiske
wants to merge
1
commit into
php:master
Choose a base branch
from
mogic-le:ssh2-auth-pubkey
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,147 @@ | ||
| <?xml version="1.0" encoding="utf-8"?> | ||
| <!-- $Revision$ --> | ||
| <refentry xmlns="http://docbook.org/ns/docbook" xml:id="function.ssh2-auth-pubkey"> | ||
| <refnamediv> | ||
| <refname>ssh2_auth_pubkey</refname> | ||
| <refpurpose>Authenticate using a public key in a variable</refpurpose> | ||
| </refnamediv> | ||
|
|
||
| <refsect1 role="description"> | ||
| &reftitle.description; | ||
| <methodsynopsis> | ||
| <type>bool</type><methodname>ssh2_auth_pubkey</methodname> | ||
| <methodparam><type>resource</type><parameter>session</parameter></methodparam> | ||
| <methodparam><type>string</type><parameter>username</parameter></methodparam> | ||
| <methodparam><type>string</type><parameter>pubkey</parameter></methodparam> | ||
| <methodparam><type>string</type><parameter>privkey</parameter></methodparam> | ||
| <methodparam choice="opt"><type>string</type><parameter>passphrase</parameter></methodparam> | ||
| </methodsynopsis> | ||
| <simpara> | ||
| Authenticate using a public key in a variable. | ||
| </simpara> | ||
| </refsect1> | ||
|
|
||
| <refsect1 role="parameters"> | ||
| &reftitle.parameters; | ||
| <variablelist> | ||
| <varlistentry> | ||
| <term><parameter>session</parameter></term> | ||
| <listitem> | ||
| <simpara> | ||
| An SSH connection link identifier, obtained from a call to | ||
| <function>ssh2_connect</function>. | ||
| </simpara> | ||
| </listitem> | ||
| </varlistentry> | ||
| <varlistentry> | ||
| <term><parameter>username</parameter></term> | ||
| <listitem> | ||
| <simpara> | ||
| Name of the user to authenticate as on the remote server. | ||
| </simpara> | ||
| </listitem> | ||
| </varlistentry> | ||
| <varlistentry> | ||
| <term><parameter>pubkey</parameter></term> | ||
| <listitem> | ||
| <simpara> | ||
| Public key in OpenSSH's format. It should look something like: | ||
| <literal>ssh-rsa AAAAB3NzaC1yc2EAAA....NX6sqSnHA8= rsa-key-20121110</literal> | ||
| </simpara> | ||
| </listitem> | ||
| </varlistentry> | ||
| <varlistentry> | ||
| <term><parameter>privkey</parameter></term> | ||
| <listitem> | ||
| <simpara> | ||
| Private OpenSSH key. It should begin with: | ||
| <literal>-----BEGIN RSA PRIVATE KEY-----</literal> | ||
| </simpara> | ||
| </listitem> | ||
| </varlistentry> | ||
| <varlistentry> | ||
| <term><parameter>passphrase</parameter></term> | ||
| <listitem> | ||
| <simpara> | ||
| If <parameter>privkey</parameter> is encrypted (which it should | ||
| be), the <parameter>passphrase</parameter> must be provided. | ||
| </simpara> | ||
| </listitem> | ||
| </varlistentry> | ||
| </variablelist> | ||
| </refsect1> | ||
|
|
||
| <refsect1 role="returnvalues"> | ||
| &reftitle.returnvalues; | ||
| <simpara> | ||
| &return.success; | ||
| </simpara> | ||
| </refsect1> | ||
|
|
||
| <refsect1 role="examples"> | ||
| &reftitle.examples; | ||
| <example> | ||
| <title>Authentication using a public key</title> | ||
| <programlisting role="php"> | ||
| <![CDATA[ | ||
| <?php | ||
| $connection = ssh2_connect('shell.example.com', 22, array('hostkey'=>'ssh-rsa')); | ||
| $publicKey = file_get_contents('/home/username/.ssh/id_rsa.pub'); | ||
| $privateKey = file_get_contents('/home/username/.ssh/id_rsa'); | ||
|
|
||
| if (ssh2_auth_pubkey($connection, 'username', | ||
| $publicKey, | ||
| $privateKey, 'secret')) { | ||
| echo "Public Key Authentication Successful\n"; | ||
| } else { | ||
| die('Public Key Authentication Failed'); | ||
| } | ||
| ?> | ||
| ]]> | ||
| </programlisting> | ||
| </example> | ||
| </refsect1> | ||
|
|
||
| <refsect1 role="notes"> | ||
| &reftitle.notes; | ||
| <note> | ||
| <simpara> | ||
| The underlying libssh library doesn't support partial auths very cleanly. | ||
| That is, if you need to supply both a public key and a password it will | ||
| appear as if this function has failed. In this particular case a failure | ||
| from this call may just mean that auth hasn't been completed yet. You | ||
| would need to ignore this failure and continue on and call | ||
| <function>ssh2_auth_password</function> in order to complete | ||
| authentication. | ||
| </simpara> | ||
| </note> | ||
| </refsect1> | ||
|
|
||
| <refsect1 role="seealso"> | ||
| &reftitle.seealso; | ||
| <simplelist> | ||
| <member><function>ssh2_auth_pubkey_file</function></member> | ||
| </simplelist> | ||
| </refsect1> | ||
|
|
||
| </refentry> | ||
| <!-- Keep this comment at the end of the file | ||
| Local variables: | ||
| mode: sgml | ||
| sgml-omittag:t | ||
| sgml-shorttag:t | ||
| sgml-minimize-attributes:nil | ||
| sgml-always-quote-attributes:t | ||
| sgml-indent-step:1 | ||
| sgml-indent-data:t | ||
| indent-tabs-mode:nil | ||
| sgml-parent-document:nil | ||
| sgml-default-dtd-file:"~/.phpdoc/manual.ced" | ||
| sgml-exposed-tags:nil | ||
| sgml-local-catalogs:nil | ||
| sgml-local-ecat-files:nil | ||
| End: | ||
| vim600: syn=xml fen fdm=syntax fdl=2 si | ||
| vim: et tw=78 syn=sgml | ||
| vi: ts=1 sw=1 | ||
| --> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.