mirror of
https://github.com/fleschutz/PowerShell.git
synced 2024-12-28 01:28:50 +01:00
Updated new-ssh-key.ps1
This commit is contained in:
parent
57bc358ec1
commit
14bb69aef0
@ -5,7 +5,8 @@
|
|||||||
This PowerShell script creates a new SSH key for the user.
|
This PowerShell script creates a new SSH key for the user.
|
||||||
.EXAMPLE
|
.EXAMPLE
|
||||||
PS> ./new-ssh-key.ps1
|
PS> ./new-ssh-key.ps1
|
||||||
✔️ Your public key: ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAILb8s5zU9YDApGQ82H45fMKVPMr5cw9fzh3PEBjZZ+Rm markus@PI
|
✔️ New SSH key with Ed25519 encryption saved to ~/.ssh - your public key is:
|
||||||
|
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAILb8s5zU9YDApGQ82H45fMKVPMr5cw9fzh3PEBjZZ+Rm markus@PI
|
||||||
.LINK
|
.LINK
|
||||||
https://github.com/fleschutz/PowerShell
|
https://github.com/fleschutz/PowerShell
|
||||||
.NOTES
|
.NOTES
|
||||||
@ -18,12 +19,15 @@ try {
|
|||||||
|
|
||||||
if (Test-Path "~/.ssh/id_ed25519.pub") {
|
if (Test-Path "~/.ssh/id_ed25519.pub") {
|
||||||
$publicKey = Get-Content "~/.ssh/id_ed25519.pub"
|
$publicKey = Get-Content "~/.ssh/id_ed25519.pub"
|
||||||
|
$enc = "Ed25519"
|
||||||
} elseif (Test-Path "~/.ssh/id_rsa.pub") {
|
} elseif (Test-Path "~/.ssh/id_rsa.pub") {
|
||||||
$publicKey = Get-Content "~/.ssh/id_rsa.pub"
|
$publicKey = Get-Content "~/.ssh/id_rsa.pub"
|
||||||
|
$enc = "RSA"
|
||||||
} else {
|
} else {
|
||||||
throw "No public key found."
|
throw "No public key found."
|
||||||
}
|
}
|
||||||
"✔️ Your public key: $publicKey"
|
"✔️ New SSH key with $enc encryption saved to ~/.ssh - your public key is:"
|
||||||
|
" $publicKey"
|
||||||
exit 0 # success
|
exit 0 # success
|
||||||
} catch {
|
} catch {
|
||||||
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||||
|
Loading…
Reference in New Issue
Block a user