Fixes #7724 – Sporadic “Permission denied (publickey,password)” errors caused by stale SSH key files on disk and stale multiplexed connections.
The existing validateSshKey() method only checked whether the key file existed (via a shell ls command) but never verified that its content matched the database. This caused three failure scenarios:
private_key_id on a server – When a server is switched to use a different SSH key, the multiplexed connection (authenticated with the old key) was not invalidated and would continue to be reused.SshMultiplexingHelper::validateSshKey() – Now uses Storage::disk('ssh-keys') to compare file content against a fresh database read (bypasses Eloquent in-memory cache). On mismatch: re-writes the key file and invalidates all mux connections for servers using that key.SshMultiplexingHelper::ensureMultiplexedConnection() – Checks whether the SSH key fingerprint has changed since the mux was established and forces a connection refresh if it has.SshMultiplexingHelper::storeConnectionMetadata() – Now also stores the key fingerprint alongside the connection timestamp for future mismatch detection.SshMultiplexingHelper::clearConnectionMetadata() – Clears both connection time and fingerprint cache entries.Server model saved event – Now invalidates the mux connection when private_key_id is changed on a server.app/Helpers/SshMultiplexingHelper.php – Core fix: content validation, fingerprint tracking, mux invalidationapp/Models/Server.php – Invalidate mux when private_key_id changestests/Unit/SshKeyContentValidationTest.php – Unit tests verifying the structural changesStorage::disk() API instead of shell commands for file operations/claim #7724
buildingvibes
@buildingvibes
Zach Latta
@zachlatta