To solve the problem, I had to edit ~/.netrc
and add
machine <gitlab server> login <user> password <password>
using a GitLab access token as password.
I also needed to add my SSH key to the ssh-agent to avoid Permission denied (publickey).
eval `ssh-agent` && ssh-add