Note

Generate a GitHub SSH key

HTTPS remotes still prompt for a username and password. Use a dedicated key on the server instead of embedding credentials.

Generate the key

ssh-keygen -t ed25519 -C "username@example.com"

When prompted for a file path, enter /home/user_name/.ssh/id_ed25519_username or leave the default id_ed25519.

Copy the contents of ~/.ssh/id_ed25519_username.pub and paste it under Settings → SSH and GPG keys in GitHub.

Switch the remote to SSH

If git pull still asks for a username and password, the remote is still HTTPS. Point it at SSH:

git remote set-url origin git@github.com:username/repo.git

Replace username/repo.git with your repository path.

Troubleshooting

Permission denied (publickey)

Add the private key to the agent:

ssh-add ~/.ssh/id_ed25519_username

Could not open a connection to your authentication agent

The agent isn't running in this session. Start it, then add the key:

eval "$(ssh-agent -s)"
ssh-add ~/.ssh/id_ed25519_username

Optional: persist the agent in .bashrc

Starting the agent every session gets old. Append this to ~/.bashrc so it starts once per login:

# Auto-start SSH agent and add key
if [ -z "$SSH_AUTH_SOCK" ]; then
    eval "$(ssh-agent -s)" > /dev/null
    ssh-add ~/.ssh/id_ed25519_username 2>/dev/null
fi

Apply immediately:

source ~/.bashrc