Added list-ssh-key.ps1

This commit is contained in:
Markus Fleschutz 2024-09-14 15:12:53 +02:00
parent 4f247ce328
commit 3fcbbeb8b0
2 changed files with 30 additions and 1 deletions

View File

@ -17,9 +17,10 @@
Write-Host "`n N E T W O R K" -foregroundColor green
& "$PSScriptRoot/list-ip-addresses.ps1"
& "$PSScriptRoot/list-ssh-key.ps1"
& "$PSScriptRoot/ping-remote-hosts.ps1"
& "$PSScriptRoot/check-firewall"
& "$PSScriptRoot/check-dns.ps1"
& "$PSScriptRoot/check-vpn.ps1"
& "$PSScriptRoot/ping-local-hosts.ps1"
exit 0 # success
exit 0 # success

28
scripts/list-ssh-key.ps1 Executable file
View File

@ -0,0 +1,28 @@
<#
.SYNOPSIS
Lists the SSH key
.DESCRIPTION
This PowerShell script lists the user's public SSH key.
.EXAMPLE
PS> ./list-ssh-key.ps1
.LINK
https://github.com/fleschutz/PowerShell
.NOTES
Author: Markus Fleschutz | License: CC0
#>
try {
if (Test-Path "~/.ssh/id_ed25519.pub") {
$key = Get-Content "~/.ssh/id_ed25519.pub"
"✅ Public SSH key is: $key"
} elseif (Test-Path "~/.ssh/id_rsa.pub") {
$key = Get-Content "~/.ssh/id_rsa.pub"
"✅ Public SSH key is: $key"
} else {
"⚠️ No SSH key found"
}
exit 0 # success
} catch {
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
exit 1
}