From 1f10d5cbe5b951401b47b5609226eccd9a1de003 Mon Sep 17 00:00:00 2001 From: Andrew Williams Date: Tue, 14 Jul 2020 20:52:45 +0100 Subject: [PATCH] Update Add-SshKey function in Windows and Linux --- bin/bin/add-sshkey | 14 ++++++++++++++ posh/Microsoft.PowerShell_profile.ps1 | 2 +- 2 files changed, 15 insertions(+), 1 deletion(-) create mode 100644 bin/bin/add-sshkey diff --git a/bin/bin/add-sshkey b/bin/bin/add-sshkey new file mode 100644 index 0000000..a121043 --- /dev/null +++ b/bin/bin/add-sshkey @@ -0,0 +1,14 @@ +#!/bin/bash + +TIMEOUT="1h" +NAME=$1 + +if [ -z "$NAME" ]; then + ssh-add -L +else + if [ -f "~/.ssh/id_ed25519_${NAME}" ]; then + ssh-add -t $TIMEOUT "~/.ssh/id_ed25519_${NAME}" + else + echo "No key named ${NAME} found..." + fi +fi \ No newline at end of file diff --git a/posh/Microsoft.PowerShell_profile.ps1 b/posh/Microsoft.PowerShell_profile.ps1 index a5d478b..a743af7 100644 --- a/posh/Microsoft.PowerShell_profile.ps1 +++ b/posh/Microsoft.PowerShell_profile.ps1 @@ -1,5 +1,5 @@ # Add a SSH key to SSH-Agent -function Add-Key { +function Add-SshKey { if ($args.Count -gt 0) { $filename = "$ENV:USERPROFILE\.ssh\id_ed25519_" + $args[0] if (!(Test-Path $filename -PathType Leaf)) {