mirror of
https://github.com/fleschutz/PowerShell.git
synced 2025-08-09 13:04:59 +02:00
Updated the manuals
This commit is contained in:
73
docs/new-ssh-key.md
Normal file
73
docs/new-ssh-key.md
Normal file
@ -0,0 +1,73 @@
|
||||
Script: *new-ssh-key.ps1*
|
||||
========================
|
||||
|
||||
This PowerShell script creates a new SSH key for the user.
|
||||
|
||||
Parameters
|
||||
----------
|
||||
```powershell
|
||||
/home/markus/Repos/PowerShell/scripts/new-ssh-key.ps1 [<CommonParameters>]
|
||||
|
||||
[<CommonParameters>]
|
||||
This script supports the common parameters: Verbose, Debug, ErrorAction, ErrorVariable, WarningAction,
|
||||
WarningVariable, OutBuffer, PipelineVariable, and OutVariable.
|
||||
```
|
||||
|
||||
Example
|
||||
-------
|
||||
```powershell
|
||||
PS> ./new-ssh-key.ps1
|
||||
✅ New SSH key of Ed25519 type saved to ~/.ssh - your public key is:
|
||||
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAILb8s5zU9YDApGQ82H45fMKVPMr5cw9fzh3PEBjZZ+Rm markus@PI
|
||||
|
||||
```
|
||||
|
||||
Notes
|
||||
-----
|
||||
Author: Markus Fleschutz | License: CC0
|
||||
|
||||
Related Links
|
||||
-------------
|
||||
https://github.com/fleschutz/PowerShell
|
||||
|
||||
Script Content
|
||||
--------------
|
||||
```powershell
|
||||
<#
|
||||
.SYNOPSIS
|
||||
Creates a new SSH key
|
||||
.DESCRIPTION
|
||||
This PowerShell script creates a new SSH key for the user.
|
||||
.EXAMPLE
|
||||
PS> ./new-ssh-key.ps1
|
||||
✅ New SSH key of Ed25519 type saved to ~/.ssh - your public key is:
|
||||
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAILb8s5zU9YDApGQ82H45fMKVPMr5cw9fzh3PEBjZZ+Rm markus@PI
|
||||
.LINK
|
||||
https://github.com/fleschutz/PowerShell
|
||||
.NOTES
|
||||
Author: Markus Fleschutz | License: CC0
|
||||
#>
|
||||
|
||||
try {
|
||||
& ssh-keygen
|
||||
if ($lastExitCode -ne "0") { throw "ssh-keygen failed" }
|
||||
|
||||
if (Test-Path "~/.ssh/id_ed25519.pub") {
|
||||
$publicKey = Get-Content "~/.ssh/id_ed25519.pub"
|
||||
$enc = "Ed25519"
|
||||
} elseif (Test-Path "~/.ssh/id_rsa.pub") {
|
||||
$publicKey = Get-Content "~/.ssh/id_rsa.pub"
|
||||
$enc = "RSA"
|
||||
} else {
|
||||
throw "No public key found."
|
||||
}
|
||||
"✅ New SSH key of $enc type saved to ~/.ssh - your public key is:"
|
||||
" $publicKey"
|
||||
exit 0 # success
|
||||
} catch {
|
||||
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||
exit 1
|
||||
}
|
||||
```
|
||||
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of new-ssh-key.ps1 as of 11/08/2024 12:34:52)*
|
Reference in New Issue
Block a user