-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbash_linux
More file actions
33 lines (28 loc) · 740 Bytes
/
bash_linux
File metadata and controls
33 lines (28 loc) · 740 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
#!/bin/bash
export PATH="$PATH:/usr/local/go/bin"
setup_ssh_agent() {
[[ ! -d ~/.ssh ]] && return
export XDG_RUNTIME_DIR="/run/user/$UID"
export DBUS_SESSION_BUS_ADDRESS="unix:path=${XDG_RUNTIME_DIR}/bus"
export SSH_AUTH_SOCK="$XDG_RUNTIME_DIR/ssh-agent.socket"
SSH_ENV="$HOME/.ssh/environment"
start_agent() {
echo "Initializing new SSH agent..."
# spawn ssh-agent
/usr/bin/ssh-agent | sed 's/^echo/#echo/' >"${SSH_ENV}"
echo succeeded
chmod 600 "${SSH_ENV}"
. "${SSH_ENV}" >/dev/null
/usr/bin/ssh-add
}
# start the ssh-agent
if [ -f "${SSH_ENV}" ]; then
. "${SSH_ENV}" >/dev/null
ps -ef | grep ${SSH_AGENT_PID} | grep ssh-agent$ >/dev/null || {
start_agent
}
else
start_agent
fi
}
setup_ssh_agent