diff --git a/README.md b/README.md index 5e4d52c..f7b3381 100644 --- a/README.md +++ b/README.md @@ -236,6 +236,21 @@ $updatedStream = $vanguard->updateNotificationStream($streamId, [ $vanguard->deleteNotificationStream($streamId); ``` +### SSH Key Management + +Retrieve the Vanguard instance SSH public key: + +```php +// Get the instance SSH public key +$sshKey = $vanguard->getInstanceSshKey(); + +// Access the public key as a string +echo $sshKey->publicKey; + +// Or cast the object to a string to get the public key +echo (string) $sshKey; +``` + ## Security For reporting security vulnerabilities, please refer to our [security policy](https://github.com/vanguardbackup/vanguard/security/policy). diff --git a/src/Actions/ManagesSshKeys.php b/src/Actions/ManagesSshKeys.php new file mode 100644 index 0000000..4641a9a --- /dev/null +++ b/src/Actions/ManagesSshKeys.php @@ -0,0 +1,20 @@ +get('ssh-key'), $this); + } +} diff --git a/src/Facades/Vanguard.php b/src/Facades/Vanguard.php index e01bbb2..93535ae 100644 --- a/src/Facades/Vanguard.php +++ b/src/Facades/Vanguard.php @@ -6,6 +6,7 @@ use Illuminate\Support\Facades\Facade; use VanguardBackup\Vanguard\Resources\ScheduledBackupTask; +use VanguardBackup\Vanguard\Resources\SshKey; use VanguardBackup\Vanguard\VanguardManager; /** @@ -13,6 +14,7 @@ * @method static \VanguardBackup\Vanguard\VanguardClient setBaseUrl(string $url) * @method static string getBaseUrl() * @method static \VanguardBackup\Vanguard\Resources\User user() + * @method static SshKey getInstanceSshKey() * @method static \VanguardBackup\Vanguard\Resources\Tag[] tags() * @method static \VanguardBackup\Vanguard\Resources\Tag tag(string $tagId) * @method static \VanguardBackup\Vanguard\Resources\Tag createTag(array $data) diff --git a/src/Resources/SshKey.php b/src/Resources/SshKey.php new file mode 100644 index 0000000..55a1d39 --- /dev/null +++ b/src/Resources/SshKey.php @@ -0,0 +1,31 @@ +publicKey = $attributes['public_key']; + } + + /** + * Get the string representation of the SSH key. + */ + public function __toString(): string + { + return $this->publicKey; + } +} diff --git a/src/VanguardClient.php b/src/VanguardClient.php index ea1bb61..9aa04d9 100644 --- a/src/VanguardClient.php +++ b/src/VanguardClient.php @@ -14,6 +14,7 @@ class VanguardClient Actions\ManagesBackupTasks, Actions\ManagesNotificationStreams, Actions\ManagesRemoteServers, + Actions\ManagesSshKeys, Actions\ManagesTags, MakesHttpRequests, ManagesBackupTaskLogs;