'permission denied for ed25519 ssh key with custom name

I'm in an Ubuntu server.

I've generated a new Ed25519 ssh key with a custom name and copied the generated public key to my Gitlab account. But when I try to clone my repository to the server. I get:

Permission denied (publickey,keyboard-interactive).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

However, I'm not facing this issue with the Ed25519 key that's generated with the default name id_ed25519 is working fine.

What's causing this issue and is there a workaround?



Solution 1:[1]

When you define custom key name, then you need to add it to ssh config, like so:

Host github.com
    HostName github.com
    User git
    IdentityFile ~/.ssh/github_private_key
    IdentitiesOnly=yes

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 user30830