PHPackages                             zpm-packages/server-access-laravel - 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. zpm-packages/server-access-laravel

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

zpm-packages/server-access-laravel
==================================

Laravel integration layer for database-backed and direct-mode server access management on top of zpm-packages/server-access.

v1.0.0(1mo ago)084↓50%1MITPHPPHP ^8.2

Since May 6Pushed 1mo agoCompare

[ Source](https://github.com/zpm-packages/server-access-laravel)[ Packagist](https://packagist.org/packages/zpm-packages/server-access-laravel)[ RSS](/packages/zpm-packages-server-access-laravel/feed)WikiDiscussions main Synced 1w ago

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

ZPMPackages Server Access Laravel
=================================

[](#zpmpackages-server-access-laravel)

Laravel integration for [zpm-packages/server-access](https://packagist.org/packages/zpm-packages/server-access). It adds Laravel service registration, Eloquent-backed synchronization, configured server resolution, direct-mode access to the current machine, scheduled sync support, and package migrations/models for server, user, and key records.

What This Package Adds
----------------------

[](#what-this-package-adds)

- Laravel service container bindings for the SSH manager resolver and helper services.
- Config-driven server access for current-system or remote-manager workflows.
- Database-backed sync for `SshServer`, `SshUser`, and `SshKey` models.
- Direct-mode records for working without syncing to database tables.
- Artisan commands to bootstrap and resync server-access tables.
- Scheduled syncing when database mode is enabled.

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

[](#installation)

```
composer require zpm-packages/server-access-laravel
```

If you want package configuration in your app:

```
php artisan vendor:publish --tag=ssh-management-config
```

If you want the package database tables:

```
php artisan migrate
```

Or let the package run the initial migration and sync flow for you:

```
php artisan ssh-management:setup-db
```

Default Config
--------------

[](#default-config)

The package exposes `config/ssh-management.php`.

```
return [
	'sync_with_database' => false,
	'allow_manager_password_update' => false,
	'database_sync_schedule' => 'hourly',
	'models' => [
		'server' => ZPMPackages\LaravelSshManagement\Models\SshServer::class,
		'user' => ZPMPackages\LaravelSshManagement\Models\SshUser::class,
		'key' => ZPMPackages\LaravelSshManagement\Models\SshKey::class,
	],
	'servers' => [
		'current-system' => [
			'name' => 'Current System',
			'host' => null,
			'port' => 22,
			'operating_system' => 'linux',
			'manager_username' => env('SSH_MANAGER_USERNAME'),
			'manager_password' => env('SSH_MANAGER_PASSWORD'),
			'is_current_system' => true,
		],
	],
];
```

Mode 1: Direct Mode
-------------------

[](#mode-1-direct-mode)

Set `sync_with_database` to `false` when you want to read and mutate the current system or configured servers without persisting SSH users and keys to the package database tables.

### Example Config

[](#example-config)

```
'sync_with_database' => false,

'servers' => [
	'current-system' => [
		'name' => 'Current System',
		'host' => null,
		'port' => 22,
		'operating_system' => PHP_OS_FAMILY === 'Windows' ? 'windows' : 'linux',
		'manager_username' => env('SSH_MANAGER_USERNAME'),
		'manager_password' => env('SSH_MANAGER_PASSWORD'),
		'is_current_system' => true,
	],
],
```

### List Configured Servers

[](#list-configured-servers)

```
use ZPMPackages\LaravelSshManagement\Services\SshDirectDataService;

$servers = app(SshDirectDataService::class)->listServers();
```

### Find a Configured Server

[](#find-a-configured-server)

```
$server = app(SshDirectDataService::class)->findServer('current-system');
```

### List Direct Users

[](#list-direct-users)

```
$users = app(SshDirectDataService::class)->listUsers('current-system');
```

### Create a Direct User

[](#create-a-direct-user)

```
$user = app(SshDirectDataService::class)->createUser([
	'username' => 'deploy',
	'name' => 'Deploy User',
	'home_directory' => '/home/deploy',
	'groups' => ['deploy', 'www-data'],
	'comment' => 'Deployment account',
	'is_root' => false,
	'can_read_entries' => true,
	'can_write_entries' => true,
	'can_manage_entries' => false,
	'managed_directories' => ['/srv/apps'],
], 'current-system');
```

### Update or Delete a Direct User

[](#update-or-delete-a-direct-user)

```
$updated = app(SshDirectDataService::class)->updateUser($user, [
	'comment' => 'Updated deployment account',
	'managed_directories' => ['/srv/apps', '/srv/releases'],
]);

app(SshDirectDataService::class)->deleteUser($updated);
```

### Create or Generate Direct Keys

[](#create-or-generate-direct-keys)

```
$manualKey = app(SshDirectDataService::class)->createKey($user, [
	'name' => 'CI key',
	'public_key' => 'ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAA... ci@runner',
	'public_key_path' => '.ssh/ci.pub',
	'private_key_path' => '.ssh/ci',
	'is_managed' => false,
]);

$generatedKey = app(SshDirectDataService::class)->generateKey($user, [
	'name' => 'deploy@host',
	'key_type' => 'ed25519',
	'passphrase' => 'secret-passphrase',
	'private_key_path' => '.ssh/deploy',
	'public_key_path' => '.ssh/deploy.pub',
]);
```

### Update or Delete Direct Keys

[](#update-or-delete-direct-keys)

```
$updatedKey = app(SshDirectDataService::class)->updateKey($user, (string) $generatedKey->getKey(), [
	'comment' => 'Rotated deploy key',
]);

app(SshDirectDataService::class)->deleteKey($user, (string) $updatedKey->getKey());
```

Mode 2: Database Sync Mode
--------------------------

[](#mode-2-database-sync-mode)

Set `sync_with_database` to `true` when you want the package models to be the app-level source of truth and have the package synchronize them to the OS/provider layer.

### Example Config

[](#example-config-1)

```
'sync_with_database' => true,
'database_sync_schedule' => 'hourly',
```

### Sync One User Model to the Provider

[](#sync-one-user-model-to-the-provider)

```
use App\Models\SshUser;
use ZPMPackages\LaravelSshManagement\Services\SshUserManagerService;

$user = SshUser::query()->with('sshServer', 'sshKeys')->findOrFail($id);

app(SshUserManagerService::class)->syncUser($user, creating: false);
```

### Create a User and Push It to the System

[](#create-a-user-and-push-it-to-the-system)

```
$user = SshUser::query()->create([
	'ssh_server_id' => $server->getKey(),
	'username' => 'deploy',
	'name' => 'Deploy User',
	'home_directory' => '/home/deploy',
	'groups' => ['deploy'],
	'comment' => 'Deployment user',
	'is_root' => false,
	'can_read_entries' => true,
	'can_write_entries' => true,
	'can_manage_entries' => false,
	'managed_directories' => ['/srv/apps'],
	'permissions' => [],
]);

app(SshUserManagerService::class)->syncUser(
	$user,
	server: $server,
	creating: true,
	keyPassphrase: 'secret-passphrase',
);
```

### Delete a Synced User

[](#delete-a-synced-user)

```
app(SshUserManagerService::class)->deleteUser($user, $server);
```

### Generate a Managed Key for an Existing User

[](#generate-a-managed-key-for-an-existing-user)

```
$key = app(SshUserManagerService::class)->generateKey(
	user: $user,
	server: $server,
	label: 'deploy@host',
	keyType: 'ed25519',
	bits: null,
	comment: 'Deploy key',
	publicKeyPath: '.ssh/deploy.pub',
	privateKeyPath: '.ssh/deploy',
	passphrase: 'secret-passphrase',
);
```

Resolver Examples
-----------------

[](#resolver-examples)

The resolver is the main way to discover configured servers and create the underlying provider manager.

```
use ZPMPackages\LaravelSshManagement\Services\SshManagerResolver;

$resolver = app(SshManagerResolver::class);

$usesDatabase = $resolver->usesDatabase();
$serverModelClass = $resolver->serverModelClass();
$currentConfiguredServer = $resolver->currentConfiguredServer();
$candidates = $resolver->listCurrentSystemUsernames();
$defaultManager = $resolver->defaultCurrentSystemUsername();

$manager = $resolver->forServer($currentConfiguredServer);
$systemUsers = $manager->scanSystemUsers();
```

System User Management Examples
-------------------------------

[](#system-user-management-examples)

```
use ZPMPackages\LaravelSshManagement\Services\SshSystemUserService;

$systemUserService = app(SshSystemUserService::class);

$candidates = $systemUserService->currentSystemManagerCandidates();
$defaultManager = $systemUserService->defaultCurrentSystemManagerUsername();

$systemUserService->changeCurrentSystemManagerUser($server, 'administrator', 'current-password');
$systemUserService->updateUserPassword($user, 'new-password');
```

Sync Commands
-------------

[](#sync-commands)

Run a full database sync:

```
php artisan ssh-management:sync
```

Run migrations plus the initial sync:

```
php artisan ssh-management:setup-db
```

Scheduling
----------

[](#scheduling)

When `sync_with_database` is enabled, the package automatically registers the scheduled sync command after Laravel resolves the scheduler. The frequency comes from `ssh-management.database_sync_schedule` and defaults to `hourly`.

Model Customization
-------------------

[](#model-customization)

You can point the package at your own Eloquent models by replacing the values in `ssh-management.models` as long as they expose the fields and relations expected by the services.

```
'models' => [
	'server' => App\Models\SshServer::class,
	'user' => App\Models\SshUser::class,
	'key' => App\Models\SshEntry::class,
],
```

Notes
-----

[](#notes)

- `can_read_entries`, `can_write_entries`, and `can_manage_entries` are explicit booleans on the user model.
- `permissions` is the structured per-user permission payload that maps to `SshPermissionEntity`.
- `changeCurrentSystemManagerUser()` only supports the current-system server flow.
- Updating the active manager user's password is blocked unless `ssh-management.allow_manager_password_update` is enabled.

###  Health Score

41

—

FairBetter than 87% of packages

Maintenance93

Actively maintained with recent releases

Popularity13

Limited adoption so far

Community5

Small or concentrated contributor base

Maturity44

Maturing project, gaining track record

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

Unknown

Total

1

Last Release

35d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/211412089?v=4)[ZPM Labs](/maintainers/zpmlabs)[@ZPMLabs](https://github.com/ZPMLabs)

### Embed Badge

![Health badge](/badges/zpm-packages-server-access-laravel/health.svg)

```
[![Health](https://phpackages.com/badges/zpm-packages-server-access-laravel/health.svg)](https://phpackages.com/packages/zpm-packages-server-access-laravel)
```

###  Alternatives

[larastan/larastan

Larastan - Discover bugs in your code without running it. A phpstan/phpstan extension for Laravel

6.4k51.0M7.4k](/packages/larastan-larastan)[psalm/plugin-laravel

Psalm plugin for Laravel

3325.1M337](/packages/psalm-plugin-laravel)[laravel/ai

The official AI SDK for Laravel.

9782.1M153](/packages/laravel-ai)[spatie/laravel-health

Monitor the health of a Laravel application

87311.3M149](/packages/spatie-laravel-health)[fumeapp/modeltyper

Generate TypeScript interfaces from Laravel Models

198306.8k](/packages/fumeapp-modeltyper)[calebdw/larastan

Larastan - Discover bugs in your code without running it. A phpstan/phpstan extension for Laravel

15104.9k4](/packages/calebdw-larastan)

PHPackages © 2026

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