Skip to content

Commit 75220bf

Browse files
author
Lou van der Laarse
committed
Merge branch 'develop'
2 parents 616c081 + f720e63 commit 75220bf

File tree

8 files changed

+22
-5
lines changed

8 files changed

+22
-5
lines changed

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,9 @@ Removes all previous loaded keys and adds the specified key to the ssh-agent for
5050
E.G: `sh load id_rsa 2` will load the id_rsa key for 2 hours.
5151
E.G: `sh load common` will load the common key for 1 hour.
5252

53+
### `sh show <keyname>`
54+
Prints the public key for they private/public key pair with the name `<keyname>`. Useful for adding the public key to services like Bitbucket, Github, etc...
55+
5356
### `sh endsession`
5457
Forcefully clear the gpg-agent files from your `masterkey` directory and clear loaded ssh keys from the ssh-agent.
5558

add

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ function load_private_key {
2323

2424
# Encrypt keys
2525
encrypt_private_keys
26+
27+
clear_gpg_agent_files
28+
kill_agent
2629
}
2730

2831
function load_full_key {
@@ -31,6 +34,8 @@ function load_full_key {
3134
decrypt_private_keys
3235
decrypt_all_keys
3336
flush_passphrase_cache
37+
clear_gpg_agent_files
38+
kill_agent
3439
untar
3540

3641
# Get private keys and copy sources.
@@ -55,6 +60,7 @@ if is_encrypted; then
5560
else
5661
load_full_key
5762
fi
63+
clear_gpg_agent_files
5864
else
5965
echo "ERROR! 'sh add' only works when the drive is encrypted!";
6066
fi

copy

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@ function copy_drive {
1717
echo "ERROR! 'sh add' only works when the drive is encrypted!" && exit 1;
1818
fi
1919

20-
clear_gpg_agent_files;
21-
2220
echo "Clearing ${FILE} ..." && ${RM_BIN} -rf ${FILE}/*;
2321

2422
echo "Copying ${DIR} to ${FILE} ..." && ${CP_BIN} -rp ${DIR}/* ${FILE}/

decrypt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ if is_encrypted; then
2424
decrypt_private_keys
2525
decrypt_all_keys
2626
flush_passphrase_cache
27+
clear_gpg_agent_files
28+
kill_agent
2729
untar
2830
else
2931
echo "Nothing to decrypt!";

endsession

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,8 @@ if [[ ! -d "$DIR" ]]; then DIR="$PWD"; fi
66
. "$DIR/script/functions"
77

88

9+
set_gpg_home
10+
flush_passphrase_cache
911
clear_gpg_agent_files
12+
kill_agent
1013
${SSH_ADD_BIN} -D

load

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,8 @@ if is_encrypted; then
6363
untar
6464
load
6565
encrypt_private_keys
66+
clear_gpg_agent_files
67+
kill_agent
6668
else
6769
echo "ERROR! Cannot load unencrypted keys! Run: \"sh encrypt\" first";
6870
fi

script/functions

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,17 +89,14 @@ function clear_gpg_agent_files {
8989
fi
9090

9191
if [ -e "${GPG_HOME_DIR}/S.gpg-agent.browser" ]; then
92-
echo "BROWSER!"
9392
${UNLINK_BIN} ${GPG_HOME_DIR}/S.gpg-agent.browser
9493
fi
9594

9695
if [ -e "${GPG_HOME_DIR}/S.gpg-agent.extra" ]; then
97-
echo "exrta!"
9896
${UNLINK_BIN} ${GPG_HOME_DIR}/S.gpg-agent.extra
9997
fi
10098

10199
if [ -e "${GPG_HOME_DIR}/S.gpg-agent.ssh" ]; then
102-
echo "ssh!"
103100
${UNLINK_BIN} ${GPG_HOME_DIR}/S.gpg-agent.ssh
104101
fi
105102
}
@@ -115,6 +112,10 @@ function flush_passphrase_cache {
115112
print_separator
116113
}
117114

115+
function kill_agent {
116+
killall gpg-agent
117+
}
118+
118119
function untar {
119120
# Untar files
120121
for file in *.tar.gz; do ${TAR_BIN} xzvf "${file}" && echo "\nTar: Completed unpacking archive, removing ${file}" && print_separator && ${RM_BIN} "${file}"; done

show

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ if is_encrypted; then
2727
untar
2828
print_public_key
2929
encrypt_all_keys
30+
clear_gpg_agent_files
31+
kill_agent
3032
else
3133
echo "ERROR! Cannot show unencrypted keys! Run: \"sh encrypt\" first";
3234
fi

0 commit comments

Comments
 (0)