Let’s say I have some private project in GitLab.
To access this project from my local machine I’m:
- Generate ssh keypair.
- Add public key to my Account (mygitlab.com/-/profile/keys).
- Do
git clone git@mygitlab.com:mygroup/myproject.giton local machine. - Work.
Then I want to deploy my project on remote production server 1.2.3.4. Ideally I want to just ssh into this server, clone my project and then do git pull every time I want to update production deployment. But I can’t access my repository from production server because there is no ssh keys in 1.2.3.4:/home/www-data/.ssh/, so if I’m trying to do git clone or git pull I get Permission denied error.
What I supposed to do in this situation?
From my opinion I should have ability to generate ssh keypair on production server and add public key to my project. But there is no way to associate public key with project – only with account. And I don’t want to associate public key for production server with my account because it’s methodologically wrong – there is many developers in our team and production server is not associated with me in any special way.
>Solution :
What I supposed to do in this situation?
Like you say, you should generate ssh keypair on production server and add public key to my project by going to repository, then on the left settings->repository and then in the middle there are "deploy keys". Paste the public key into deploy keys and choose a unique name. After that, you can use that key to clone. There is also documentation https://docs.gitlab.com/ee/user/project/deploy_keys/ .