1. Go to this page and download the library: Download k2gl/sshsig library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
k2gl / sshsig example snippets
use K2gl\Sshsig\AllowedSigners;
use K2gl\Sshsig\Exception\SshsigException;
use K2gl\Sshsig\SshsigVerifier;
$verifier = new SshsigVerifier;
try {
$result = $verifier->verify(
message: file_get_contents('release.tar.gz'),
armoredSignature: file_get_contents('release.tar.gz.sig'),
allowedSigners: AllowedSigners::fromFile('allowed_signers'),
identity: '[email protected]',
namespace: 'file',
);
echo "Verified: {$result->publicKey->fingerprint()}\n";
} catch (SshsigException $e) {
// not verified — malformed, unsupported, bad signature, or unauthorized signer
echo "Rejected: {$e->getMessage()}\n";
}
use K2gl\Sshsig\Ed25519SigningKey;
use K2gl\Sshsig\OpensshPrivateKey;
use K2gl\Sshsig\OpensslSigningKey;
use K2gl\Sshsig\SshsigSigner;
// Ed25519
$keypair = sodium_crypto_sign_keypair();
$signer = new SshsigSigner(new Ed25519SigningKey(sodium_crypto_sign_secretkey($keypair)));
// …or RSA / ECDSA from an OpenSSL private key (PEM)
$signer = new SshsigSigner(OpensslSigningKey::fromPem(file_get_contents('id_rsa')));
// …or an unencrypted ssh-ed25519 key straight off disk, in the format ssh-keygen writes
$signer = new SshsigSigner(OpensshPrivateKey::fromFile('/home/you/.ssh/id_ed25519'));
$armored = $signer->sign($message, namespace: 'file'); // sha512 by default
file_put_contents('message.sig', $armored);
// the resulting signature verifies with `ssh-keygen -Y verify` and with this library
$allowed = AllowedSigners::fromString(<<<TXT
# comments and blank lines are ignored
[email protected] ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAA…
*@example.com namespaces="git,file" ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAA…
TXT);
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.