mirror of
https://github.com/cmderdev/cmder.git
synced 2024-11-10 09:49:12 +08:00
Move ssh-agent logic to lib script
This commit is contained in:
parent
0c9e0e2f8c
commit
7e1bc4297a
22
vendor/lib/start-ssh-agent.sh
vendored
Normal file
22
vendor/lib/start-ssh-agent.sh
vendored
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
# Copied from https://help.github.com/articles/working-with-ssh-key-passphrases
|
||||||
|
env=~/.ssh/agent.env
|
||||||
|
|
||||||
|
agent_load_env () { test -f "$env" && . "$env" >| /dev/null ; }
|
||||||
|
|
||||||
|
agent_start () {
|
||||||
|
(umask 077; ssh-agent >| "$env")
|
||||||
|
. "$env" >| /dev/null ; }
|
||||||
|
|
||||||
|
agent_load_env
|
||||||
|
|
||||||
|
# agent_run_state: 0=agent running w/ key; 1=agent w/o key; 2= agent not running
|
||||||
|
agent_run_state=$(ssh-add -l >| /dev/null 2>&1; echo $?)
|
||||||
|
|
||||||
|
if [ ! "$SSH_AUTH_SOCK" ] || [ $agent_run_state = 2 ]; then
|
||||||
|
agent_start
|
||||||
|
ssh-add
|
||||||
|
elif [ "$SSH_AUTH_SOCK" ] && [ $agent_run_state = 1 ]; then
|
||||||
|
ssh-add
|
||||||
|
fi
|
||||||
|
|
||||||
|
unset env
|
29
vendor/user_profile.sh.default
vendored
29
vendor/user_profile.sh.default
vendored
@ -3,30 +3,5 @@
|
|||||||
# To add a new vendor to the path, do something like:
|
# To add a new vendor to the path, do something like:
|
||||||
# export PATH=${CMDER_ROOT}/vendor/whatever:${PATH}
|
# export PATH=${CMDER_ROOT}/vendor/whatever:${PATH}
|
||||||
|
|
||||||
function launch_ssh_agent {
|
# Uncomment this to have the ssh agent load with the first bash terminal
|
||||||
# Copied from (https://help.github.com/articles/working-with-ssh-key-passphrases)
|
# . "${CMDER_ROOT}/vendor/lib/start-ssh-agent.sh"
|
||||||
env=~/.ssh/agent.env
|
|
||||||
|
|
||||||
agent_load_env () { test -f "$env" && . "$env" >| /dev/null ; }
|
|
||||||
|
|
||||||
agent_start () {
|
|
||||||
(umask 077; ssh-agent >| "$env")
|
|
||||||
. "$env" >| /dev/null ; }
|
|
||||||
|
|
||||||
agent_load_env
|
|
||||||
|
|
||||||
# agent_run_state: 0=agent running w/ key; 1=agent w/o key; 2= agent not running
|
|
||||||
agent_run_state=$(ssh-add -l >| /dev/null 2>&1; echo $?)
|
|
||||||
|
|
||||||
if [ ! "$SSH_AUTH_SOCK" ] || [ $agent_run_state = 2 ]; then
|
|
||||||
agent_start
|
|
||||||
ssh-add
|
|
||||||
elif [ "$SSH_AUTH_SOCK" ] && [ $agent_run_state = 1 ]; then
|
|
||||||
ssh-add
|
|
||||||
fi
|
|
||||||
|
|
||||||
unset env
|
|
||||||
}
|
|
||||||
|
|
||||||
# Run ssh-agent automatically when you open your first bash terminal
|
|
||||||
# launch_ssh_agent
|
|
Loading…
Reference in New Issue
Block a user