PHPackages                             codeaken/sshkey - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. codeaken/sshkey

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

codeaken/sshkey
===============

Library for working with and generating SSH keys

1.2(9y ago)1261.4k—5.3%4[2 issues](https://github.com/codeaken/sshkey/issues)[2 PRs](https://github.com/codeaken/sshkey/pulls)1MITPHPPHP &gt;=5.4.0

Since Oct 22Pushed 5y ago2 watchersCompare

[ Source](https://github.com/codeaken/sshkey)[ Packagist](https://packagist.org/packages/codeaken/sshkey)[ RSS](/packages/codeaken-sshkey/feed)WikiDiscussions master Synced 2d ago

READMEChangelog (2)Dependencies (2)Versions (4)Used By (1)

SshKey
======

[](#sshkey)

This library allows you to work with public and private keys in PHP.

- Read keys both from a file and from other sources like a database
- Convert between key formats
- Get a public keys fingerprint
- Generate new key-pairs

It depends on [phpseclib](https://github.com/phpseclib/phpseclib) for all of the key manipulation.

Installation
------------

[](#installation)

Require the package in your **composer.json** and then run `composer update`

```
"require": {
    ...
    "codeaken/sshkey": "1.*"
    ...
},

```

Usage
-----

[](#usage)

These examples makes the following assumptions:

- The library is autoloaded, for example by having included `vendor/autoload.php` somewhere in your project
- You have a a key-pair in your current directory called `id_rsa` (private) and `id_rsa.pub` (public). The private key is not encrypted.
- An encrypted private key in your current directory called `id_encrypted_rsa` protected by the password `abc123`

### Read a key from a file

[](#read-a-key-from-a-file)

```
