/claim #7724
Fixes sporadic ‘Permission denied (publickey)’ errors caused by stale SSH key data.
The bug occurs due to three interconnected issues:
Eloquent Relationship Caching: When a Server model is loaded (especially via Server::findCached() or ownedByCurrentTeamCached()), the $server->privateKey relationship may return stale data if the key was changed in the database after the Server was loaded.
File-Only Validation: The previous validateSshKey() only checked if the key file exists using ls, not whether its content matches the database. A corrupted or stale file would pass validation.
Stale Multiplexed Connections: SSH multiplexing (ControlMaster) keeps connections alive that may have authenticated with an old key. When the key changes, these connections aren’t invalidated.
PrivateKey model from the database before validation, bypassing any Eloquent cachingStorage::disk('ssh-keys')app/Helpers/SshMultiplexingHelper.php: Enhanced validateSshKey() method with:
The fix ensures that:
Erdogan Kervanli
@erdogan98
Zach Latta
@zachlatta