Added ssh-with-timeout for ssh-agent usage with password-protected keys
This commit is contained in:
@@ -15,5 +15,6 @@ unset SSH_ASKPASS
|
|||||||
eval "`dircolors -b $DIR_COLORS`"
|
eval "`dircolors -b $DIR_COLORS`"
|
||||||
|
|
||||||
export PATH=$PATH:$HOME/.local/bin
|
export PATH=$PATH:$HOME/.local/bin
|
||||||
|
alias ssh=$HOME/.local/bin/ssh-with-timeout.sh
|
||||||
|
|
||||||
#### END MAGIC VALUE: AZSQFRB8
|
#### END MAGIC VALUE: AZSQFRB8
|
||||||
|
|||||||
@@ -18,13 +18,8 @@
|
|||||||
default = simple
|
default = simple
|
||||||
[core]
|
[core]
|
||||||
editor = vim
|
editor = vim
|
||||||
|
sshCommand = /home/anaber/.local/bin/ssh-with-timeout.sh
|
||||||
[pull]
|
[pull]
|
||||||
ff = only
|
ff = only
|
||||||
[http]
|
[http]
|
||||||
postBuffer = 524288000
|
postBuffer = 524288000
|
||||||
sslcainfo = /etc/ssl/certs/ca-certificates.crt
|
|
||||||
[filter "lfs"]
|
|
||||||
clean = git-lfs clean -- %f
|
|
||||||
smudge = git-lfs smudge -- %f
|
|
||||||
process = git-lfs filter-process
|
|
||||||
required = true
|
|
||||||
|
|||||||
2
setup.sh
2
setup.sh
@@ -25,7 +25,7 @@ done
|
|||||||
|
|
||||||
echo "Copying scripts"
|
echo "Copying scripts"
|
||||||
mkdir -p "${HOME}/.local/bin"
|
mkdir -p "${HOME}/.local/bin"
|
||||||
script_copy_list=(update-dns.sh gentags)
|
script_copy_list=(update-dns.sh gentags ssh-with-timeout.sh)
|
||||||
for script in ${script_copy_list[@]}; do
|
for script in ${script_copy_list[@]}; do
|
||||||
cp -fr "${script}" "${HOME}/.local/bin/${script}"
|
cp -fr "${script}" "${HOME}/.local/bin/${script}"
|
||||||
done
|
done
|
||||||
|
|||||||
31
ssh-with-timeout.sh
Executable file
31
ssh-with-timeout.sh
Executable file
@@ -0,0 +1,31 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
SSH_ENV="$HOME/.ssh/environment"
|
||||||
|
|
||||||
|
function load_key_file {
|
||||||
|
local key_rsp="$(ssh-add -L 2>&1)"
|
||||||
|
if [[ "${key_rsp}" == *"The agent has no identities"* ]]; then
|
||||||
|
ssh-add /home/anaber/.ssh/id_rsa
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
function start_ssh_agent {
|
||||||
|
ssh-agent | sed 's/^echo/#echo/' > "${SSH_ENV}"
|
||||||
|
}
|
||||||
|
|
||||||
|
if [ ! -e "${SSH_ENV}" ]; then
|
||||||
|
start_ssh_agent
|
||||||
|
. "${SSH_ENV}" > /dev/null
|
||||||
|
else
|
||||||
|
. "${SSH_ENV}" > /dev/null
|
||||||
|
ps -ef | grep ${SSH_AGENT_PID} | grep -q ssh-agent$ || {
|
||||||
|
start_ssh_agent
|
||||||
|
}
|
||||||
|
. "${SSH_ENV}" > /dev/null
|
||||||
|
fi
|
||||||
|
export SSH_AGENT_PID
|
||||||
|
export SSH_AUTH_SOCK
|
||||||
|
|
||||||
|
load_key_file
|
||||||
|
# Pass command line arguments to ssh
|
||||||
|
/usr/bin/ssh $@
|
||||||
Reference in New Issue
Block a user