Can not clone from gitlab using ssh
I have installed on DigitalOcean my GitLab (GitServer) and it is running Ok. I also have on DigitalOcean a LAMP stack (WebServer) and it is running Ok.
I successfully can clone into my computer any repo from my GitServer, I have added my ssh key to GitServer.
I also have added my WebServer's SSH key to my GitServer, but I can not clone from it.
This is what I get:
sudo git clone git@GitServer:group/repo.git
Cloning into 'repo'...
git@GitServer: Permission denied (publickey).
fatal: Could not read from remote repository.
Maybe Im missing something, I have followed tons of tutorials with no luck.
Thanks for your help.
EDIT - AFTER ALL FEEDBACK FOUND MY ANSWER
Please take note that the command I used was:
sudo git clone git@GitServer:group/repo.git
The SSH key that I added to my server was my user's SSH key. After creating a new pair of keys for root user and adding it to my GitServer, no more Permission denied (publickey) issue.
This will be solved either adding your user to the www-data group and giving right permissions to the /var/www/ folder (and not cloning using sudo) or just use sudo and add the root's SSH key to the server, like I did at the end.
Thanks for all the feedback.
ubuntu ssh gitlab
add a comment |
I have installed on DigitalOcean my GitLab (GitServer) and it is running Ok. I also have on DigitalOcean a LAMP stack (WebServer) and it is running Ok.
I successfully can clone into my computer any repo from my GitServer, I have added my ssh key to GitServer.
I also have added my WebServer's SSH key to my GitServer, but I can not clone from it.
This is what I get:
sudo git clone git@GitServer:group/repo.git
Cloning into 'repo'...
git@GitServer: Permission denied (publickey).
fatal: Could not read from remote repository.
Maybe Im missing something, I have followed tons of tutorials with no luck.
Thanks for your help.
EDIT - AFTER ALL FEEDBACK FOUND MY ANSWER
Please take note that the command I used was:
sudo git clone git@GitServer:group/repo.git
The SSH key that I added to my server was my user's SSH key. After creating a new pair of keys for root user and adding it to my GitServer, no more Permission denied (publickey) issue.
This will be solved either adding your user to the www-data group and giving right permissions to the /var/www/ folder (and not cloning using sudo) or just use sudo and add the root's SSH key to the server, like I did at the end.
Thanks for all the feedback.
ubuntu ssh gitlab
Does the WebServer's user have read access to the repository? This error is usually either mismatched keys or a user permission issue.
– Alex Mitchell
Jan 2 at 3:07
The only user in the WebServer is me, and I am the owner of the repo. Or maybe Im missing something here?
– Eduardo Sánchez
Jan 2 at 3:25
add a comment |
I have installed on DigitalOcean my GitLab (GitServer) and it is running Ok. I also have on DigitalOcean a LAMP stack (WebServer) and it is running Ok.
I successfully can clone into my computer any repo from my GitServer, I have added my ssh key to GitServer.
I also have added my WebServer's SSH key to my GitServer, but I can not clone from it.
This is what I get:
sudo git clone git@GitServer:group/repo.git
Cloning into 'repo'...
git@GitServer: Permission denied (publickey).
fatal: Could not read from remote repository.
Maybe Im missing something, I have followed tons of tutorials with no luck.
Thanks for your help.
EDIT - AFTER ALL FEEDBACK FOUND MY ANSWER
Please take note that the command I used was:
sudo git clone git@GitServer:group/repo.git
The SSH key that I added to my server was my user's SSH key. After creating a new pair of keys for root user and adding it to my GitServer, no more Permission denied (publickey) issue.
This will be solved either adding your user to the www-data group and giving right permissions to the /var/www/ folder (and not cloning using sudo) or just use sudo and add the root's SSH key to the server, like I did at the end.
Thanks for all the feedback.
ubuntu ssh gitlab
I have installed on DigitalOcean my GitLab (GitServer) and it is running Ok. I also have on DigitalOcean a LAMP stack (WebServer) and it is running Ok.
I successfully can clone into my computer any repo from my GitServer, I have added my ssh key to GitServer.
I also have added my WebServer's SSH key to my GitServer, but I can not clone from it.
This is what I get:
sudo git clone git@GitServer:group/repo.git
Cloning into 'repo'...
git@GitServer: Permission denied (publickey).
fatal: Could not read from remote repository.
Maybe Im missing something, I have followed tons of tutorials with no luck.
Thanks for your help.
EDIT - AFTER ALL FEEDBACK FOUND MY ANSWER
Please take note that the command I used was:
sudo git clone git@GitServer:group/repo.git
The SSH key that I added to my server was my user's SSH key. After creating a new pair of keys for root user and adding it to my GitServer, no more Permission denied (publickey) issue.
This will be solved either adding your user to the www-data group and giving right permissions to the /var/www/ folder (and not cloning using sudo) or just use sudo and add the root's SSH key to the server, like I did at the end.
Thanks for all the feedback.
ubuntu ssh gitlab
ubuntu ssh gitlab
edited Jan 5 at 23:04
Eduardo Sánchez
asked Jan 2 at 3:01
Eduardo SánchezEduardo Sánchez
115
115
Does the WebServer's user have read access to the repository? This error is usually either mismatched keys or a user permission issue.
– Alex Mitchell
Jan 2 at 3:07
The only user in the WebServer is me, and I am the owner of the repo. Or maybe Im missing something here?
– Eduardo Sánchez
Jan 2 at 3:25
add a comment |
Does the WebServer's user have read access to the repository? This error is usually either mismatched keys or a user permission issue.
– Alex Mitchell
Jan 2 at 3:07
The only user in the WebServer is me, and I am the owner of the repo. Or maybe Im missing something here?
– Eduardo Sánchez
Jan 2 at 3:25
Does the WebServer's user have read access to the repository? This error is usually either mismatched keys or a user permission issue.
– Alex Mitchell
Jan 2 at 3:07
Does the WebServer's user have read access to the repository? This error is usually either mismatched keys or a user permission issue.
– Alex Mitchell
Jan 2 at 3:07
The only user in the WebServer is me, and I am the owner of the repo. Or maybe Im missing something here?
– Eduardo Sánchez
Jan 2 at 3:25
The only user in the WebServer is me, and I am the owner of the repo. Or maybe Im missing something here?
– Eduardo Sánchez
Jan 2 at 3:25
add a comment |
2 Answers
2
active
oldest
votes
It looks like a permissions issue.
Your ssh key is not authorized - Permission denied (publickey)
.
You need to create a public ssh key and to add the ssh public key again, delete older one.
Thanks for your answer. Already did this, no luck. :(
– Eduardo Sánchez
Jan 2 at 3:31
Is it ok with HTTPS?
– Shafikur Rahman
Jan 2 at 3:31
Yes, via https is ok, but I need it via SSH. I think Im missing something.
– Eduardo Sánchez
Jan 2 at 3:33
1
Actually, I added the SSH Key to my profile
– Eduardo Sánchez
Jan 2 at 3:41
1
Thanks for your answer and time, please review my edits to the question and you will see the answer there. Your feedback was important to get to the key solution.
– Eduardo Sánchez
Jan 5 at 23:09
|
show 8 more comments
Do I need to have a git user in my WebServer?
That is what git@GitServer
means: "connect to GitServer
as user git
".
Your GitLab server should be running as user git
.
That also means your public key must be added to ~git/.ssh/authorized_keys
for any SSH-related operation to have a chance to work.
That should be done automatically by GitLab on your remote server when you add your key to your profile.
Check the output of ssh -Tv git@GitServer
; you should see a Welcome message.
Using sudo
means your public/private keys must be in /root/.ssh
, for a sudo git clone git@...
command to complete an ssh session successfully.
After your answer and some more debugging, I found out that I was trying to clone from my user but connected as root. This was the reason why the SSH key was not working. Will continue to test and let you all know. Thanks again!
– Eduardo Sánchez
Jan 2 at 6:27
Thanks for your answer and time, please review my edits to the question and you will see the answer there. Your feedback was important to get to the key solution.
– Eduardo Sánchez
Jan 5 at 23:08
@EduardoSánchez That seems coherent: using sudo means root has the keys. I have edited my answer accordingly.
– VonC
Jan 5 at 23:14
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54000760%2fcan-not-clone-from-gitlab-using-ssh%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
It looks like a permissions issue.
Your ssh key is not authorized - Permission denied (publickey)
.
You need to create a public ssh key and to add the ssh public key again, delete older one.
Thanks for your answer. Already did this, no luck. :(
– Eduardo Sánchez
Jan 2 at 3:31
Is it ok with HTTPS?
– Shafikur Rahman
Jan 2 at 3:31
Yes, via https is ok, but I need it via SSH. I think Im missing something.
– Eduardo Sánchez
Jan 2 at 3:33
1
Actually, I added the SSH Key to my profile
– Eduardo Sánchez
Jan 2 at 3:41
1
Thanks for your answer and time, please review my edits to the question and you will see the answer there. Your feedback was important to get to the key solution.
– Eduardo Sánchez
Jan 5 at 23:09
|
show 8 more comments
It looks like a permissions issue.
Your ssh key is not authorized - Permission denied (publickey)
.
You need to create a public ssh key and to add the ssh public key again, delete older one.
Thanks for your answer. Already did this, no luck. :(
– Eduardo Sánchez
Jan 2 at 3:31
Is it ok with HTTPS?
– Shafikur Rahman
Jan 2 at 3:31
Yes, via https is ok, but I need it via SSH. I think Im missing something.
– Eduardo Sánchez
Jan 2 at 3:33
1
Actually, I added the SSH Key to my profile
– Eduardo Sánchez
Jan 2 at 3:41
1
Thanks for your answer and time, please review my edits to the question and you will see the answer there. Your feedback was important to get to the key solution.
– Eduardo Sánchez
Jan 5 at 23:09
|
show 8 more comments
It looks like a permissions issue.
Your ssh key is not authorized - Permission denied (publickey)
.
You need to create a public ssh key and to add the ssh public key again, delete older one.
It looks like a permissions issue.
Your ssh key is not authorized - Permission denied (publickey)
.
You need to create a public ssh key and to add the ssh public key again, delete older one.
answered Jan 2 at 3:29
Shafikur RahmanShafikur Rahman
2,03731226
2,03731226
Thanks for your answer. Already did this, no luck. :(
– Eduardo Sánchez
Jan 2 at 3:31
Is it ok with HTTPS?
– Shafikur Rahman
Jan 2 at 3:31
Yes, via https is ok, but I need it via SSH. I think Im missing something.
– Eduardo Sánchez
Jan 2 at 3:33
1
Actually, I added the SSH Key to my profile
– Eduardo Sánchez
Jan 2 at 3:41
1
Thanks for your answer and time, please review my edits to the question and you will see the answer there. Your feedback was important to get to the key solution.
– Eduardo Sánchez
Jan 5 at 23:09
|
show 8 more comments
Thanks for your answer. Already did this, no luck. :(
– Eduardo Sánchez
Jan 2 at 3:31
Is it ok with HTTPS?
– Shafikur Rahman
Jan 2 at 3:31
Yes, via https is ok, but I need it via SSH. I think Im missing something.
– Eduardo Sánchez
Jan 2 at 3:33
1
Actually, I added the SSH Key to my profile
– Eduardo Sánchez
Jan 2 at 3:41
1
Thanks for your answer and time, please review my edits to the question and you will see the answer there. Your feedback was important to get to the key solution.
– Eduardo Sánchez
Jan 5 at 23:09
Thanks for your answer. Already did this, no luck. :(
– Eduardo Sánchez
Jan 2 at 3:31
Thanks for your answer. Already did this, no luck. :(
– Eduardo Sánchez
Jan 2 at 3:31
Is it ok with HTTPS?
– Shafikur Rahman
Jan 2 at 3:31
Is it ok with HTTPS?
– Shafikur Rahman
Jan 2 at 3:31
Yes, via https is ok, but I need it via SSH. I think Im missing something.
– Eduardo Sánchez
Jan 2 at 3:33
Yes, via https is ok, but I need it via SSH. I think Im missing something.
– Eduardo Sánchez
Jan 2 at 3:33
1
1
Actually, I added the SSH Key to my profile
– Eduardo Sánchez
Jan 2 at 3:41
Actually, I added the SSH Key to my profile
– Eduardo Sánchez
Jan 2 at 3:41
1
1
Thanks for your answer and time, please review my edits to the question and you will see the answer there. Your feedback was important to get to the key solution.
– Eduardo Sánchez
Jan 5 at 23:09
Thanks for your answer and time, please review my edits to the question and you will see the answer there. Your feedback was important to get to the key solution.
– Eduardo Sánchez
Jan 5 at 23:09
|
show 8 more comments
Do I need to have a git user in my WebServer?
That is what git@GitServer
means: "connect to GitServer
as user git
".
Your GitLab server should be running as user git
.
That also means your public key must be added to ~git/.ssh/authorized_keys
for any SSH-related operation to have a chance to work.
That should be done automatically by GitLab on your remote server when you add your key to your profile.
Check the output of ssh -Tv git@GitServer
; you should see a Welcome message.
Using sudo
means your public/private keys must be in /root/.ssh
, for a sudo git clone git@...
command to complete an ssh session successfully.
After your answer and some more debugging, I found out that I was trying to clone from my user but connected as root. This was the reason why the SSH key was not working. Will continue to test and let you all know. Thanks again!
– Eduardo Sánchez
Jan 2 at 6:27
Thanks for your answer and time, please review my edits to the question and you will see the answer there. Your feedback was important to get to the key solution.
– Eduardo Sánchez
Jan 5 at 23:08
@EduardoSánchez That seems coherent: using sudo means root has the keys. I have edited my answer accordingly.
– VonC
Jan 5 at 23:14
add a comment |
Do I need to have a git user in my WebServer?
That is what git@GitServer
means: "connect to GitServer
as user git
".
Your GitLab server should be running as user git
.
That also means your public key must be added to ~git/.ssh/authorized_keys
for any SSH-related operation to have a chance to work.
That should be done automatically by GitLab on your remote server when you add your key to your profile.
Check the output of ssh -Tv git@GitServer
; you should see a Welcome message.
Using sudo
means your public/private keys must be in /root/.ssh
, for a sudo git clone git@...
command to complete an ssh session successfully.
After your answer and some more debugging, I found out that I was trying to clone from my user but connected as root. This was the reason why the SSH key was not working. Will continue to test and let you all know. Thanks again!
– Eduardo Sánchez
Jan 2 at 6:27
Thanks for your answer and time, please review my edits to the question and you will see the answer there. Your feedback was important to get to the key solution.
– Eduardo Sánchez
Jan 5 at 23:08
@EduardoSánchez That seems coherent: using sudo means root has the keys. I have edited my answer accordingly.
– VonC
Jan 5 at 23:14
add a comment |
Do I need to have a git user in my WebServer?
That is what git@GitServer
means: "connect to GitServer
as user git
".
Your GitLab server should be running as user git
.
That also means your public key must be added to ~git/.ssh/authorized_keys
for any SSH-related operation to have a chance to work.
That should be done automatically by GitLab on your remote server when you add your key to your profile.
Check the output of ssh -Tv git@GitServer
; you should see a Welcome message.
Using sudo
means your public/private keys must be in /root/.ssh
, for a sudo git clone git@...
command to complete an ssh session successfully.
Do I need to have a git user in my WebServer?
That is what git@GitServer
means: "connect to GitServer
as user git
".
Your GitLab server should be running as user git
.
That also means your public key must be added to ~git/.ssh/authorized_keys
for any SSH-related operation to have a chance to work.
That should be done automatically by GitLab on your remote server when you add your key to your profile.
Check the output of ssh -Tv git@GitServer
; you should see a Welcome message.
Using sudo
means your public/private keys must be in /root/.ssh
, for a sudo git clone git@...
command to complete an ssh session successfully.
edited Jan 5 at 23:13
answered Jan 2 at 5:58
VonCVonC
848k29826983255
848k29826983255
After your answer and some more debugging, I found out that I was trying to clone from my user but connected as root. This was the reason why the SSH key was not working. Will continue to test and let you all know. Thanks again!
– Eduardo Sánchez
Jan 2 at 6:27
Thanks for your answer and time, please review my edits to the question and you will see the answer there. Your feedback was important to get to the key solution.
– Eduardo Sánchez
Jan 5 at 23:08
@EduardoSánchez That seems coherent: using sudo means root has the keys. I have edited my answer accordingly.
– VonC
Jan 5 at 23:14
add a comment |
After your answer and some more debugging, I found out that I was trying to clone from my user but connected as root. This was the reason why the SSH key was not working. Will continue to test and let you all know. Thanks again!
– Eduardo Sánchez
Jan 2 at 6:27
Thanks for your answer and time, please review my edits to the question and you will see the answer there. Your feedback was important to get to the key solution.
– Eduardo Sánchez
Jan 5 at 23:08
@EduardoSánchez That seems coherent: using sudo means root has the keys. I have edited my answer accordingly.
– VonC
Jan 5 at 23:14
After your answer and some more debugging, I found out that I was trying to clone from my user but connected as root. This was the reason why the SSH key was not working. Will continue to test and let you all know. Thanks again!
– Eduardo Sánchez
Jan 2 at 6:27
After your answer and some more debugging, I found out that I was trying to clone from my user but connected as root. This was the reason why the SSH key was not working. Will continue to test and let you all know. Thanks again!
– Eduardo Sánchez
Jan 2 at 6:27
Thanks for your answer and time, please review my edits to the question and you will see the answer there. Your feedback was important to get to the key solution.
– Eduardo Sánchez
Jan 5 at 23:08
Thanks for your answer and time, please review my edits to the question and you will see the answer there. Your feedback was important to get to the key solution.
– Eduardo Sánchez
Jan 5 at 23:08
@EduardoSánchez That seems coherent: using sudo means root has the keys. I have edited my answer accordingly.
– VonC
Jan 5 at 23:14
@EduardoSánchez That seems coherent: using sudo means root has the keys. I have edited my answer accordingly.
– VonC
Jan 5 at 23:14
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54000760%2fcan-not-clone-from-gitlab-using-ssh%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Does the WebServer's user have read access to the repository? This error is usually either mismatched keys or a user permission issue.
– Alex Mitchell
Jan 2 at 3:07
The only user in the WebServer is me, and I am the owner of the repo. Or maybe Im missing something here?
– Eduardo Sánchez
Jan 2 at 3:25