Ssh key error "Host key verification failed."

My general rule of thumb is if it ain’t broke don’t fix it. If it works for you why bother going about removing it. Just like plymouth it works for some it doesn’t for others. BTW,

about this. You might wanna take a look at archwiki and add the script in your .bashrc or .config/fish/config.fish depending on which shell you are using by default so that you can use the same instance of ssh-agent across multiple terminal emulators and have only one instance of ssh-agent running.

https://wiki.archlinux.org/title/SSH_keys#ssh-agent

for bash

if ! pgrep -u "$USER" ssh-agent > /dev/null; then
    ssh-agent -t 1h > "$XDG_RUNTIME_DIR/ssh-agent.env"
fi
if [[ ! -f "$SSH_AUTH_SOCK" ]]; then
    source "$XDG_RUNTIME_DIR/ssh-agent.env" >/dev/null
fi

for config.fish

if ! pgrep -u "$USER" ssh-agent > /dev/null;
ssh-agent -c -t 1h > "$XDG_RUNTIME_DIR/ssh-agent.env"
end
if [ ! -f "$SSH_AUTH_SOCK" ];
source "$XDG_RUNTIME_DIR/ssh-agent.env" >/dev/null
end

Remember you can’t have it in both choose one. Since placing this script in both would just issue errors. Or you can change the location of ssh-agent environment file so that both bash and fish use separate instances of ssh-agent.

Following this you won’t have to run eval "$(ssh-agent -s)" ever again. You just need to add the ssh key to ssh-agent using ssh-add. Oh the script also uses -t 1h which asks ssh-agent to keep the ssh password for 1h and then you need to add it again to ssh-agent if you wanna use it. You can remove this flag and have ssh-agent remember your ssh password until reboots.

2 Likes