-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathssh-keyphrase-only-once.installer
executable file
·38 lines (34 loc) · 1.7 KB
/
ssh-keyphrase-only-once.installer
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
#!/usr/bin/env bash
#########################################################################
# Only type in your SSH keyphrase once per boot. #
# #
# Installs a script and configures OpenSSH so that you are only #
# prompted for your SSH keyphrase *once* per system boot. #
# #
# Part of HopeSeekr's BashScripts Collection #
# https://github.com/hopeseekr/BashScripts/ #
# #
# Copyright © 2020 Theodore R. Smith <[email protected]> #
# GPG Fingerprint: 4BF8 2613 1C34 87AC D28F 2AD8 EB24 A91D D612 5690 #
# #
# License: Creative Commons Attribution v4.0 International #
#########################################################################
# Bail out if ~/.bash_profile already has the code.
# @see https://stackoverflow.com/a/4749368/430062
if ! grep -Fq "Run ssh-agent ONCE" ~/.bash_profile; then
cat <<'LAUNCH_SSH_AGENT' >> ~/.bash_profile
# Run ssh-agent ONCE per user per system boot.
# [installed via https://github.com/hopeseekr/BashScripts]
# @see https://unix.stackexchange.com/a/217223/15780
if [ ! -S ~/.ssh/ssh_auth_sock ]; then
eval `ssh-agent`
ln -sf "$SSH_AUTH_SOCK" ~/.ssh/ssh_auth_sock
fi
export SSH_AUTH_SOCK=~/.ssh/ssh_auth_
LAUNCH_SSH_AGENT
fi
if ! grep -Fqx "AddKeysToAgent yes" ~/.ssh/config ; then
echo "" >> ~/.ssh/config
echo "AddKeysToAgent yes" >> ~/.ssh/config
fi
source ~/.bash_profile