blob: c7d2249d538de4ff94d52285236e1f9fb743c462 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
|
#!/bin/sh
# We can figure out the password for the key based on $1
# which is in the following form:
# Enter passphrase for key 'path/to/key':
# The point is to retrieve the path where the filename is the name of
# the key.
# Then we can construct the path for pass and get the password.
key="$(printf '%s\n' "$1" |
cut -f 2 -d \' |
awk -F '/' '{print $NF}')"
pass="keys/$(hostname)/ssh/$key"
# optional: add key to running ssh-agent
keyadd "$key" &
pass show "$pass" | head -n 1
|