aboutsummaryrefslogtreecommitdiff
path: root/ssh-agent-loadkey
blob: e02bd1f44ce434d87dc28a95c00bd1d4a48f8d77 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#!/bin/bash
#
# Load a key into the ssh-agent
#

# Parameters
BASENAME="`basename $0`"
TYPE="$1"
HANDLE="$2"

# Check
if [ -z "$HANDLE" ]; then
  echo "usage: $BASENAME <keytype> <handle>"
  echo "available keys:"
  echo ""
  ( cd $HOME/.ssh/keys && find -name '*.pub' ) | grep -v decomissioned | sed -e 's/^/\t/'
  exit 1
elif [ ! -e "$HOME/.ssh/keys/$TYPE/$HANDLE" ]; then
  echo "$BASENAME: file not found: $HOME/.ssh/keys/$TYPE/$HANDLE"
  exit 1
fi

# Dispatch
ssh-add $HOME/.ssh/keys/$TYPE/$HANDLE