Function to add ed25519 ssh-key to ssh-agent

This commit is contained in:
gardouille 2021-09-19 18:43:53 +02:00
parent 2b7c59f8ab
commit b1ce539942
Signed by: gardouille
GPG Key ID: E759BAA22501AF32
2 changed files with 12 additions and 0 deletions

2
zshenv
View File

@ -105,3 +105,5 @@ fi
## Specify ssh-agent socket path
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"

10
zshrc
View File

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