Function to add rsa ssh-key to ssh-agent

This commit is contained in:
gardouille 2021-09-19 18:56:04 +02:00
parent b1ce539942
commit 8841520957
Signed by: gardouille
GPG Key ID: E759BAA22501AF32
2 changed files with 11 additions and 0 deletions

1
zshenv
View File

@ -107,3 +107,4 @@ SSH_AGENT_SOCK="${HOME}/.ssh/socks/ssh_auth"
SSH_AGENT_ENV="${HOME}/.ssh/socks/ssh_agent_env"
## ssh-keys path
SSH_ED25519_KEY="${HOME}/.ssh/id_ed25519"
SSH_RSA_KEY="${HOME}/.ssh/id_rsa"

10
zshrc
View File

@ -345,6 +345,16 @@ function load-ssh-ed25519() {
fi
}
# }}}
# Add rsa ssh-key to ssh-agent {{{
function load-ssh-rsa() {
# If a RSA ssh-key is available
# AND not already loaded in ssh-agent
if [ -f "${SSH_RSA_KEY}" ] &&
! ssh-add -l | grep -qi -- "(rsa)"; then
ssh-add "${SSH_RSA_KEY}"
fi
}
# }}}
# Clear old entries in known_hosts {{{
function clearsshkey() {
sed -i "${1}d" ~/.ssh/known_hosts