PHPackages                             pagemachine/authorized-keys - 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. pagemachine/authorized-keys

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

pagemachine/authorized-keys
===========================

Read, edit and write the SSH authorized\_keys file

2.2.1(3mo ago)1169.2k↑135.9%2[1 issues](https://github.com/pagemachine/authorized-keys/issues)[2 PRs](https://github.com/pagemachine/authorized-keys/pulls)GPL-3.0-or-laterPHPPHP ^8.2CI passing

Since Feb 8Pushed 2w ago2 watchersCompare

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

READMEChangelog (6)Dependencies (20)Versions (19)Used By (0)

Authorized Keys [![CI](https://github.com/pagemachine/authorized-keys/workflows/CI/badge.svg)](https://github.com/pagemachine/authorized-keys/workflows/CI/badge.svg)
=====================================================================================================================================================================

[](#authorized-keys-)

Read, edit and write the SSH `authorized_keys` file.

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

[](#installation)

```
composer require pagemachine/authorized-keys

```

Usage
-----

[](#usage)

To access the `authorized_keys` file an instance of `Pagemachine\AuthorizedKeys\AuthorizedKeys` must be created, either directly passing the file content to the constructor or using the static `fromFile()` method:

```
$path = '/home/foo/.ssh/authorized_keys';
$authorizedKeys = AuthorizedKeys::fromFile($path);
```

You can easily iterate all keys in the file, comments and empty lines will be skipped:

```
foreach ($authorizedKeys as $key) {
    // Do something with $key
}

```

To add a key, create an instance of `Pagemachine\AuthorizedKeys\PublicKey` and add it to the file:

```
// ... load $authorizedKeys ...
$key = new PublicKey('ssh-rsa AAA...');
$authorizedKeys->addKey($key);
```

Notice that each key is only added once, if you add it again, only its options, type and comment are updated accordingly. Thus it's safe to call this method in any case to ensure keys are present.

To remove a key, wrap it in `PublicKey` and remove it from the file:

```
// ... load $authorizedKeys ...
$key = new PublicKey('ssh-rsa AAA...');
$authorizedKeys->removeKey($key);
```

To close things off, write back the file, comments and empty lines will be left unchanged:

```
$authorizedKeys->toFile($path);
```

The permissions of the file will be changed to 0600, namely readable and writable by the owner but nobody else.

Testing
-------

[](#testing)

All tests can be executed with the shipped Docker Compose definition:

```
docker compose run --rm app composer build

```

###  Health Score

61

—

FairBetter than 98% of packages

Maintenance87

Actively maintained with recent releases

Popularity38

Limited adoption so far

Community15

Small or concentrated contributor base

Maturity84

Battle-tested with a long release history

 Bus Factor1

Top contributor holds 94% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~664 days

Recently: every ~826 days

Total

6

Last Release

110d ago

Major Versions

1.0.1 → 2.0.02017-12-19

PHP version history (5 changes)1.0.0PHP ^5.6 || ^7.0

2.0.0PHP ^7.0

2.1.0PHP ^7.3 || ^8.0

2.2.0PHP ^7.4 || ^8.0

2.2.1PHP ^8.2

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/10812548?v=4)[Pagemachine AG](/maintainers/pagemachine)[@pagemachine](https://github.com/pagemachine)

---

Top Contributors

[![mbrodala](https://avatars.githubusercontent.com/u/5037116?v=4)](https://github.com/mbrodala "mbrodala (221 commits)")[![renovate[bot]](https://avatars.githubusercontent.com/in/2740?v=4)](https://github.com/renovate[bot] "renovate[bot] (8 commits)")[![renovate-bot](https://avatars.githubusercontent.com/u/25180681?v=4)](https://github.com/renovate-bot "renovate-bot (3 commits)")[![patrickhilker](https://avatars.githubusercontent.com/u/5042280?v=4)](https://github.com/patrickhilker "patrickhilker (1 commits)")[![sschuett](https://avatars.githubusercontent.com/u/1898111?v=4)](https://github.com/sschuett "sschuett (1 commits)")[![vokeit-gschuster](https://avatars.githubusercontent.com/u/56930714?v=4)](https://github.com/vokeit-gschuster "vokeit-gschuster (1 commits)")

---

Tags

authorized-keysphppublic-keysshsshpublic keyauthorized\_keys

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan, Rector

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/pagemachine-authorized-keys/health.svg)

```
[![Health](https://phpackages.com/badges/pagemachine-authorized-keys/health.svg)](https://phpackages.com/packages/pagemachine-authorized-keys)
```

###  Alternatives

[spatie/ssh

A lightweight package to execute commands over an SSH connection

8393.1M57](/packages/spatie-ssh)[herzult/php-ssh

Provides an object-oriented wrapper for the php ssh2 extension.

3591.2M12](/packages/herzult-php-ssh)[sop/crypto-encoding

A PHP implementation of textual encodings of cryptographic structures.

171.5M28](/packages/sop-crypto-encoding)[sop/crypto-types

A PHP library of various ASN.1 types for cryptographic applications.

121.4M35](/packages/sop-crypto-types)[codeaken/sshkey

Library for working with and generating SSH keys

1261.4k1](/packages/codeaken-sshkey)[yohang/oossh

Object Oriented SSH for PHP

363.8k](/packages/yohang-oossh)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
