pagemachine/authorized-keys 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

pagemachine/authorized-keys

最新稳定版本:2.2.0

Composer 安装命令:

composer require pagemachine/authorized-keys

包简介

Read, edit and write the SSH authorized_keys file

README 文档

README

Read, edit and write the SSH authorized_keys file.

Installation

composer require pagemachine/authorized-keys

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

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

docker compose run --rm app composer build

统计信息

  • 总下载量: 59.18k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 11
  • 点击次数: 3
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 11
  • Watchers: 2
  • Forks: 2
  • 开发语言: PHP

其他信息

  • 授权协议: GPL-3.0-or-later
  • 更新时间: 未知

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固