Skip to content

GitLab for newbies, like me – Permission denied (publickey)

If you just created your GitLab account, there is a big chance that you miss the part with adding some SSH keys to your account. In this case, you can’t push your commits from the console. It is normal

And is normal to take this error message:

[email protected]: Permission denied (publickey).
fatal: Could not read from remote repository.

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

Solve the problem in Ubuntu

The secret is to generate an SSH key and add it to Account -> Settings -> SSH Keys (in the left menu)

Follow the short instruction below or learn how to create an SSH key from this link – https://docs.gitlab.com/ee/ssh/#options-for-ssh-keys

To do it in MS Windows you need a package named “Git for Windows” (open source) and especially the Git Bash so can execute the SSH commands – download here

Short (optional enter  passphrase):

ssh-keygen -t ed25519 -C "email for example or computer name"

To copy the content of the key in linux:

xclip -sel clip < ~/.ssh/id_ed25519.pub

To copy from the Git Bash (Windows)

cat /c/Users/<edit user>/.ssh/id_ed25519.pub | clip

Go to Account -> Settings -> SSH Keys and paste the key

Add keys for all your machines

Views: 111

Leave a Reply

Your email address will not be published. Required fields are marked *