-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathkey.html
More file actions
38 lines (32 loc) · 914 Bytes
/
key.html
File metadata and controls
38 lines (32 loc) · 914 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
---
layout: null
permalink: /key/
---
#!/usr/bin/env bash
# copyright (c) 2017 Tom Dunlap
# based on lpass-add copyright (c) 2016 Luke Turner
# Released under MIT License (SPDX:MIT)
set -o errexit
set -o nounset
set -o pipefail
readonly LPASS_USER=tdunlap@pivotal.io
readonly KEY_NAME=personal_key
TEMP_CERT_FILE=$(mktemp)
readonly TEMP_CERT_FILE
onexit() {
local EXIT_CODE=$?
echo "Removing temporary file $TEMP_CERT_FILE"
rm "$TEMP_CERT_FILE"
if [[ $EXIT_CODE == 0 ]]; then
echo "lpass-add: identity added successfully"
else
echo "lpass-add: failed to add identity $KEY_NAME"
echo "Script exited with code $EXIT_CODE"
fi
}
trap onexit EXIT
LPASS_DISABLE_PINENTRY=1 lpass login $LPASS_USER
echo "Writing key $KEY_NAME to temporary file $TEMP_CERT_FILE"
lpass show --notes "$KEY_NAME" > "$TEMP_CERT_FILE"
echo "Adding SSH key $KEY_NAME"
ssh-add -t 28800 "$TEMP_CERT_FILE"